The people who use ads effectively are buying pay per click and measuring the real conversions to measure effectiveness. Bots don't buy the products after they click through, but the real clicks often do. (For some categories you can get as high as 10% conversion rate to a real sale from real clicks that you buy because ad targeting on platforms like Facebook and Amazon is really, really good. If your ad is good and your product is good then the ad targeting will get your ad in front of the right people a lot of the time.)
If you are smart you don't pay for impressions, you pay for clicks and conversions, and you measure how many of those clicks convert into sales to make sure you are coming out net positive. Sure there are always going to be some fake clicks but there are still enough real clicks that convert to make it worth it. A bit of click fraud is just the cost of doing business.
Lets say I'm selling a product that has a 20% profit margin. I might be willing to pay up to 10% of my profit margin on ads if the increased number of real conversions that result will more than double my sales, allowing me to make more money overall than I would have otherwise.
There are definitely a lot of people out there who are foolishly wasting money on buying impressions, but there are also tons of people making ludicrous amounts of money from well targeted ads that convert into increased sales of their product