Imam al Ghazali (may Allah have mercy upon him) gives an interesting discussion whereby this topic is addressed. Of course the time within which the Imam lived is much different than ours, however for those of reflection it will insha’Allah provide much food for thought. He explains that there exist towns wherein there are many scholars of jurisprudence, a great blessing. However, in such towns despite the abundance of knowledge in the field of fiqh there was no resident doctor. The latter of which he explains is a communal obligation (fard kifayah).
Communal obligations differ from personal obligations (fard ayn) in that personal obligations must be done by all people at all times. An example of a personal obligation is the prayer; everyone must do it at all times. Of course, a certain level of religious knowledge is required upon every individual. Communal obligations, on the other hand, are requirements that the community as a collective must fulfill. And, when that community responsibility is not done then the entire group is in sin. A common example of this is religious leadership; this is needed and required to call the community to Islam and assist in the performance of communal religious obligations.
Allah, by His Knowledge and immense Mercy, did not create an Ummah (nation) of religious scholars. Rather, we are diverse in our skills, passions, abilities and knowledge. At this point we can return to the point made by Imam al Ghazali (may Allah have mercy on him). Those communities with many religious scholars were not fulfilling the communal obligation of having a doctor for the people. This is not the fault of any single person, rather it is the community which must recognize the need of a certain knowledge and/or profession and ensure that it is available for the betterment of society.