It is possibly easier to answer 'where do babies come from.'
Pop-ups are varied and can come from many sources, some of which are legitimate, but no less a pain in the rear.
Many web sites have pop-ups when you visit pages and there are also pop-unders that open behind the window you are viewing and when you close that do you see it. Installing some softwaare can result in 'targeted' ads, that may be in the form of pop-ups or other means, ads in the actual pages you are viewing. Some toolbars monitor your browsing activity, again to deliver adverts.
No matter what they are pop-ups however they originate, the why will be no different to any conventional ad, marketing to make money.