Aligning prices with purchasing power allows pharmaceutical companies to get _something_ out of the markets they'd get nothing out of. And with large numbers, that something might turn out to be a bit more.
Sure production cost is usually low and that technically allows to sell to poor countries essentially at cost plus a tiny margin.
But that's only half the story. Drugs need to be developed. From idea to market only a tiny fraction of medication makes it. You need studies ovet studies, and most of the time a drug does not make it through that process because it's ineffective or dangerous or both. The few that make it need to compensate for the cost of this process, not just their own but all of those that didn't make it.
So, in "rich" countries, a pill that costs $0.10 to produce can easily cost $1000. That's a necessity to finance the whole process of getting there.
After that is all done and established, sure, you may get that same pill for $1 since it's either that or no sale. But that does not mean the whole system would work for $1 per pill everywhere in the world. Then the pill would not exist in the first place.
I doubt the American people (or American industry) would ever allow such a truly free market system to transpire, but I know for a fact it can work.
Labor is cheaper in Tanzania obviously, but even if you adjusted for the more expensive labor, a free market system (vs the crony capitalist system we have now) would probably be 10-100x cheaper.
Also, even controlling for median wage, the drugs are vastly cheaper in Tanzania vs America. A median worker there might make around $5-10 in wage, so most drugs for a month supply would be only a day of work. Median hourly wage in America of $15 would correspond to drug prices between $60-120 dollars, much cheaper than most medications without insurance. In reality, it should be much cheaper, as the marginal cost can be reduced a lot through online pharmacies (remember that $5-10 cost in Tanzania not only factors in product cost and labor cost, but a staggeringly inefficient distribution network).
In short, I don't believe there's any theoretical reason why generic drugs couldn't be dirt cheap and affordable by all in a free market system. After all, capitalism has done a stellar job at reducing the cost of consumer goods over time, and medication should be no different.
If everyone could buy lightly regulated pills from alibaba, it would definitely be a win from a utility standpoint. But of course such a thing would never fly, as maximizing total utility doesn't get people elected. Everyone might win except one guy who died from bad pills and the whole gig would be up, even though the total utility function of every citizen in aggregate was being correctly maximized.
The strong needs of the few always trumps the weak needs of the many. If everyone paid one $1 dollar per day in order to prevent one death, I'm sure some politician would call it a massive win, even though that's an aggregate loss of 100bn dollars annually and the money saved generated more utility than the utility lost by that one guy dying.
Unfortunately, human beings are unable to make correct statistical/utilitarian decisions and support so many policies that are a net negative utility wise.