The other big example of this problem is the massive overgrowth of the FIRE sector, which has largely eaten the US economy whole while accomplishing nothing other than its own enrichment.
[0] For the purposes of this argument, 'actual stuff' does apply to intangible goods, like software, that expands the production possibilities curve.
I have worked in this industry on and off for almost a decade now, and in general, advertising is only used for users who will never pay. I mean, it makes sense right?
You can get $5 for one IAP, and if you are incredibly lucky $5 CPM which is 1000 impressions. In-app advertising is a tiny, tiny percentage of revenue for most mobile gaming companies.
That being said, everyone spends on it because the best way to find people who'll play mobile games is to target people who play mobile games.
Cross-promotion also exists in just about every other media format (books, TV, movies...).
The problem is of course not unique to software. Eg. it may be more lucrative for drug companies to research hair-loss or acne drugs than something like cholera.
This doesn't seem especially unreasonable; hair loss and acne, to the extent they are problems, are unsolved problems. Nobody disputes that cholera is a problem, but it is very much a solved problem.
I completely agree with you that this causes a misallocation of resources, but mental health is probably not the best example you could have chosen.