The original point was that advertising increases their resources by more than its cost. If they spend $X to get $X+ then the "+" is additional resources that both increase the incentive to do R&D and provide more resources to do it with.
Moreover, the only way advertising makes them money is by more people using the drug. Presumably the additional people taking the drug derive some value from it (or why take it?), so that isn't inherently a loss to society. If the value of taking the drug is worth more than what they're paying then it's a benefit.
The biggest problem here is probably when you have insurance paying most of the price of something, so then the patient sees an ad for a drug which is 2% better and costs 2000% more, but the fact that the benefit isn't worth the money is removed from the patient's calculation when the insurance is paying for it, and then that causes everyone's premiums/taxes to go up. But the problem in that case isn't the advertising -- that's just the mechanism -- the problem is the misalignment of incentives caused by widespread low deductible insurance.
After you spend a couple billion per launch to make a new drug, then you spend another couple billion on marketing. Again, I could be mistaken, but I'm pretty sure that's the position of pharma.