I can say with confidence that >90% of new small-molecule pharmaceuticals would not be created in a patent-free world. Now, not every new small molecule drug is important, in fact probably the majority aren’t. But those that are, save a lot of lives.
The market for pharmaceuticals is already very far from being a free market. It's a heavily regulated industry with extremely high compliance costs. In this specific case, further market distortions in the form of patent monopolies might be necessary to make the market work. Most industries do not have this level of regulation.
The economic harm to society that comes from patents is more than enough to fund public research that could employ the same smart people to discover the same medicines.