Perhaps you prefer: A company must think it's likely that they'll have a good return on all development costs, not just the costs of drugs that happen to be successful, to continue to invest.
> if profits are high, the industry expands to try more kinds of drugs, stopping when the attempts on the margin are just profitable enough (on average).
Of course, something like pharmaceutical products, with exclusive sales of specific products, few sellers, strategic conduct relative to other industries (insurers), and heavy regulatory influence is not guaranteed to converge to normal profit.
In reality many failures are early or first round failures. Not free but a small fraction of the price of getting to market.
So to you example a 90% failure rate may only require a 2x or 3x return on your successes to “break even”.
https://www.nature.com/articles/nrd.2016.136
"They found that the probability of success was 63% in Phase I trials, 31% in Phase II trials, 58% in Phase III trials and 85% during the regulatory review process"
42% failure rates in phase 3 is enormously high. By then you've pretty much spent 90%+ of all the cost of getting a drug approved.
[1] Which isn't to say there's zero cost for Phase 1 or Phase 2, but it's a lot lot less than Phase 3 trials.
[2] 1,000 drugs, 63%, 630 of which make it through Phase 1. In Phase 2, 195 drugs, 31% of 630 succeed and make it through to Phase 3, and then 82 drugs (58% of 195) make it to regulatory approval.
So despite attrition that reduces candidates by 9x by phase 3, costs have increased by 8x.
[1]https://www.sofpromed.com/how-much-does-a-clinical-trial-cos...
If you're looking at the total amount spent by "the economy" (drug development costs X% of GDP), sure. If you're looking at "why are drug prices so high", it probably doesn't make sense to to include costs funded from other places (which in this example I assume would be research grants ie taxes, and venture capital funds).