Like, you could imagine a system where you don't have a free market at all, the government would directly fund both medical treatment (like in Europe) and medical research (like nowhere right now, but you could imagine nationalizing the drug companies). So then, before the hepatitis-c drug exists, you are paying $500k for each liver transplant, and you try to figure out how much money should be allocated to that drug research program. You'd want to fund it at roughly the expected cost saving, multiplied by the probability that the drug development is successful.
In the actual system, if the drug companies try to develop the drugs, and then charge about the same price as the cost of the previous treatment during the time they hold the patent, then their expected payoff (so how much money they will put into research) is the cost of the previous treatment times the probability that they will be successful---so this high price is basically what we would want to allocate anyway. And if the drugs are paid for by the government, their expected spending over all the drugs is similar to optimal amount of direct research funding.