Why email spam is on the decline

February 7, 2013, 7:48 PM UTC

FORTUNE — Those weird little ads on the right side of your Facebook page—the ones depicting ugly shoes or pitching iffy continuing education degrees—are partly the result of the changing economics of both spam and online advertising in general.

Email spam became a huge business—and a huge problem for both Internet users and network managers—because marginal costs are near zero. Once a sleazy pitch for gray-market Viagra or a porn site is written, the additional cost of each spam message sent is almost nothing. Sending out millions of emails doesn’t cost much more than sending out just one. Very few people fall for the usually scammy offers, so sending them in bulk is necessary to actually snag paying customers.

But improvements to spam-blocking technologies, together with ever-cheaper “legit” advertising have worked to decrease email spam, according to a report from Kaspersky Lab, a maker of antivirus software. “With the emergence of Web 2.0,” the report states, “advertising opportunities on the Internet have skyrocketed: banners, context-based advertising, and ads on social networks and blogs.”

MORE: 5 tech turnarounds that actually worked

The percentage of email identified as spam is still huge—72.1% in 2012, according to the report. But it’s been dropping every year recently, and is the lowest it’s been in five years.

“Ads in legal advertising venues are not as irritating for users on the receiving end,” according to the report. And the economics have shifted so much that it’s actually cheaper in many cases to buy banner-ad space than to spam. Kaspersky estimates that the cost-per-click (the total cost to get one user to click on a link) is about $4.45 for spam, but only about 10 cents for a Facebook  ad.

Hence the cheesy ads you see on Facebook (FB) and elsewhere. The report explicitly states as much: The “classic spam categories (such as fake luxury goods, for example) are now switching over to social networks. We have even found some IP addresses for online stores advertising on Facebook that were previously using spam.”

Erstwhile spammers are also making use of online-coupon services such as Groupon (GRPN). Welcome to the wonderful world of online advertising.