Take Auryxia which is literally ferric citrate. Its used by kidney patients to control phosphorus levels and boost iron. Why did it take so long to get tested and approved as a drug when the formula was "open source" for a long time? Well one company did the time and effort and suddenly it is considered a valuable drug. The value came from proving the safety and efficacy and someone has to be willing to fund it.
The long line of failed drugs are the real issue.
Sure, just the trial might cost that little if it’s an orphan disease, but it’s also ignoring all the other stuff that goes along with running a trial. Things like manufacturing, compliance, data analysis, etc.
When you look at the total cost of R&D for a drug, it’s typically 1/3 for discovery and 2/3 for development (clinical trials).
If your drug is used in any reasonable sized population, development is easily in the hundreds of millions of dollars.
You are correct about the failure rates though.