Advertising, in the modern sense, is, well, modern. You pretty much simply did not have goods to advertise (or the means to advertise them) other than for very specific items -- think classifieds rather than bulk and mass advertising.
The rise of the factory system, of transport networks, and the capacity to create far more of a good than local demand could absorb created the first modern-style advertising in about 1860. The first prominently-featured adverts were the 19th century equivalents of Viagra ads: mostly-ineffective patent medicines.
Hamilton Holt has a delightful contemporary account of this, written (and presented as a lecture, it's short) in 1909, looking back on the previous 50 years or so of publishing history. I cannot recommend it highly enough.
In fact, that’s how Google started out with AdSense as well: It was called “content targeting advertising”, because Google scanned your webpage and then served ads that related to the content of your webpage.
I don’t know what happened along the road to lead us to the current tracking and spying mess.
What happened is the ad landscape shifted from targeting placements and content to targeting audiences and where they are in their journey to purchase. It simply performs better for advertisers and it's often more scalable. In turn, this makes the platform more money because sites that may have low value inventory can suddenly be sold for higher CPMs if an advertiser for example wants to bid on their retargeting data in the auction. It let's them price based on people.
New media just outsources all the hard work to Google and other big ad placers. Easier but you lose editorial control over your work.