I didn't say that, and I think it's simplistic to think that the costs are to offset the losses incurred with a failed drug. On the contrary, quite a bit of that cost is offset the investment needed to get a drug to the clinic. Whether that is through the expense of the research, the purchase acquisition of a small startup with a promising candidate (who don't have the $$ to take it to the clinic), the length and complexity of the clinical trial, or even the expense and complexity of manufacturing the drug. It's all part of it.
There are other considerations too. There was a huge controversy when the first drugs to treat people with Hepatitis C. Previously, this was a horrible diagnosis - you were going to get liver cancer, and the only 'treatment' would be to manage the disease while waiting for a liver transplant. But, compared to what many are used to for other medications, the cost of new Hep C treatment - about $84k - seems like lunacy. But after 8, 16, or 24 weeks of treatment, 95% of people are cured. In reality, the pricing may be reasonable considering the costs associated with ongoing Hep C disease. It's far more expense to get a liver transplant and live with chronic disease. None of this is easy to unpack.
That last example also flies in the face of 'drug companies don't want to cure people because then they don't have patients anymore'. Again, it's a business, and business can be cutthroat, but everyplace I've worked, the goal - in oncology, autoimmunity and infectious disease - the focus has always been on bringing the best benefit to the largest number of patients. And working for the cure.