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...