On the supply side the inputs for the pharmaceutical industry aren't infinite.
Whether it's chemists, chemicals, warehouse space, machinery, or time all of these things are rivalrous. When you put a chemist on one project you take them away from another. If you put a chemical in one drug you take it away from another. If you make a factory produce one drug it stops producing another.
In order to solve the problem of maximizing the benefit of the resources being used we can use a market that uses prices and profits to coordinate itself, or we can have a group of really smart people trying to reason out what is needed where. Markets are historically good at solving this type of problem, bureaucrats are historically bad at it.