The religious scholars (Ulama) never shirked their role of reminding the kings of their social duty. Most of the scholars refrained from accepting any government post so that they might not have to yield to any undue pressure. They thought that by remaining independent they would be able to play their role of censuring the policies of the government and of reminding the rulers of their duties.
That is why in later periods of Islamic history, when dynastic rule had become the order of the day among the Muslims, the rulers, more or less, could not deviate far from the Islamic principles of justice. For instance, the ruler had to come to the mosque to pray with the public; he had to spend the money of the treasury to fulfil the requirements of the public; he had to discharge his religious responsibilities and see to it that the public had no difficulty in discharging religious rites. Anyone could approach the king to register his or her complaint. And there was a proper arrangement by the government for the free religious education of the people, etc.