Unfortunately for the lower classes, there were many points in history in which a populace was at the mercy of an unstable or even insane sovereign ruler. Due to the frequency with which royal families internarried, mental and physical defects were more common than in normal populations. These were wildly different times, in which life wasn't generally valued as it is today, and the jealousy and competition for the throne between royal family members led to betrayals and murders.
An interesting article at i09 describes ten instances in which, not only did a mentally ill person reign over a region, but their actions as rulers brought about a significant change in the history of said region. Below is the story of number four on the list, the story of Sultan Mustafa of the Ottoman Empire, who reigned from 1617–18 and from 1622–23.
Ahmed I and Mustafa were royal brothers. At the time, it was expected that a sultan would have his brothers executed after he took the throne, in order to eliminate any competition for his position. (Mustafa and Ahmed's father Mehmed III executed 19 of his own brothers after he became sultan.) Ahmed took the throne at 13, at which time he sent his brother Mustafa, 11, to "the cage." The cage was a tower with no windows. There, Mustafa had no human contact.
When Ahmed died of typhus at age 28, his most powerful concubine argued against his eldest son taking the throne as, due to the custom of the sultan executing his brothers, she rightfully feared her sons by Ahmed would be killed. Thus Mustafa, who according to some sources had an intellectual disability from birth, was let out of the cage. He had been isolated there for fourteen years, which certainly had no positive effect on his mental state.
Reportedly always accompanied by two naked slave girls, Mustafa caused numerous problems as a leader. One was that he would appoint random people he liked to powerful posts in his kingdom. With untrained people in positions of power and the demented Mustafa in charge, the empire deteriorated. After only one year as sultan, Mustafa was again sent to the cage, along with his slave girls.
At that time, Ahmed's eldest son Osman took the throne and was a fairly competent leader. Yet when he banned his military from drinking and smoking, there was such a backlash against him that he was put to death by "compression of the testicles."
After Osman was killed, Mustafa was once again let out of the cage and given the throne. By that time, his mental health had declined to the point that he would stare off into space, giggling to himself at some unseen source. He also frequently sought out his nephew Osman, the former sultan, continually forgetting that Osman had been put to death. The Ottoman empire quickly began to disintegrate, at which time the Safavid Persian empire attacked the region and took control. Mustafa went to the cage again, never to re-emerge.
Read about other mentally ill monarchs whose actions (or inactions) changed history here.