“You shall surely appoint a king over you!” (Devarim 17:15)
It is a positive commandment to appoint a Jewish king over us so that he can gather us all together and lead us like his will, and about this it says “You shall surely appoint a king over you!”.
Amongst the roots of this commandment are that it is a huge achievement for people to have one leader over them, as the inhabitation of the world in peace cannot happen without this.
Amongst the laws of this commandment are that one may only appoint a king over the nation of Klal Yisrael to rule if the high court consisting of seventy-one judges appoints him, and the prophet agrees. This we see with Yehoshua who was appointed by our teacher Moshe and his court of law, and also with Sha’ul and David who were appointed by the prophet Shmuel and his court of law. When crowning a king, he is anointed with the special anointing oil. After his appointment, he merits to keep the kingship forever and to pass it on to his sons, as the verse says explicitly “In order that he will have long days over his kingdom, he and his sons in the midst of Yisrael!”. If he only leaves behind him a son who is a minor, we keep the kingdom for him until he grows up. The relative who is first in line for inheritance, takes precedence for the kingship as well, and the older son takes precedence over the younger one.
This is not only true about kingship, for the law is that any position of importance or power whether it is a position where one needs to act, and whether it is a position which has just an honored title, follow the rules of inheritance and the person owns the position like an inheritance where the son can inherit it after him, and so on and so forth forever. All of this is only on condition that the son who fills his father’s position also fills it in regards to fear of heaven. However, one who has no fear of heaven, even if he has much wisdom, may not be appointed to any position in Klal Yisrael.
The commandment is to fear the king, and to accept his words about everything that he commands so long as it is not contradicting the Torah, and to honor and respect him with ultimate degree of honor and respect which can be given to mere flesh and blood, and if anyone transgresses the commandment of the king who has been appointed using the correct procedures according to the Torah, or rebels against him in any way, the king has the power and the right to execute him, and there is not even a hint of sin in so doing.
The king also has the right to judge people according to that which appears to him to be the truth even without clear witnesses.
This commandment applies when Klal Yisrael are living on their land.