Making a profit on pills is just one motivation in a very complex system of competing motivations, incentives and regulations that shape what "we" prioritise.
I think drawing conclusions from one specific motivation in isolation is too simplistic. Many other profit interests benefit greatly from a healthy population that doesn't spend all its money on useless pills.
And motivations other than profit, both personal and political, are very powerful as well.
I don't think there is much evidence that eliminating the profit motivation leads to better results in general -- on the contrary. But there is a lot of evidence from Europe that health systems with public buyer cartels can achieve the same or better health outcomes far cheaper than in the US.
Although some say that sky high US drug prices effectively subsidise those European outcomes.