But wouldn't the pharmaceutical companies do it themselves in-house then?
Transitioning from “nice idea” to “consumer product” is a vast chasm. Most people that do not actually have experience taking things from research to production grossly under-estimate the amount of effort involved. From a purely economic perspective, the “research” part of the total bill is dwarfed by the activity required to turn it into a salable product.