EDIT
I should clarify - since investors know they have to pay for 100% of restaurants, of which 90% will fail, they price this in when they decide to invest in a restaurant.
Drug companies have to pay for all ten trials, not just the one that works out.
Restaurants are a bad example because people invest in it on an emotional basis. Drug trials are probably decided on more the same basis as bond issues or insurance.
If the risk of failure is high, investors have to demand a high premium or go broke.
They run at some % loss for a while until money or investor patience runs out.
A drug trial that fails can be a 10 year process of shoveling money in a pit, none of it to be ever seen again.
It's a businesses famous for its low succes rates, which can be from start to end less than 1 in 100.
Drug companies need to offer those who provide the capital to run these experimental projects at huge losses for years a way to recoup their losses - otherwise nobody would be willing to fund the effort.
The way to do that is patent and charge absurdly high prices for those few succesfull drugs that are developed for as long as you can.
Unless you're asking why there is not a single state-run drug company doing everything, in which the case the answer is scale has disadvantages, having some diverse set of companies in a space like this has advantages, and state run centralism has been debunked so many times I can't be arsed.