A lot of basic research (including medicinal) is funded by governments who are not in it to make a lot of money. Sure, medical companies who then develop drugs based on this decades of knowledge and research are profit-oriented, but that's only one part of the equation.