Within the Law, God made a provision for an earthly king or lesser king (i.e., vassal) who would represent the people before Him.
- When you enter the land which the Lord your God gives you, and you possess it and live in it, and you say, I will set a king over me like all the nations who are around me, you shall surely set a king over you whom the Lord your God chooses, one from among your countrymen you shall set as king over yourselves; you may not put a foreigner over yourselves who is not your countryman. - Deuteronomy 17:14-15
Specifically, the king would be Jewish and chosen by YHWH. As such, the king was anointed by God to the task. The king’s chief function was to learn, read, and observe the Law
- Now it shall come about when he sits on the throne of his kingdom, he shall write for himself a copy of this law on a scroll in the presence of the Levitical priests. It shall be with him and he shall read it all the days of his life, that he may learn to fear the Lord his God, by carefully observing all the words of this law and these statutes, - Deuteronomy 17:18-19
- Keep the charge of the Lord your God, to walk in His ways, to keep His statutes, His commandments, His ordinances, and His testimonies, according to what is written in the Law of Moses, that you may succeed in all that you do and wherever you turn, - 1 Kings 2:3
The king was to be the key teacher and enforcer of the Law. Being the Law’s guardian, he was granted limited powers to adjudicate, enforce punishments, and execute lawbreakers. However, the king did not control the judicial system. The Law established a judiciary of priests, with the high priest serving as the judge. If the king violated God’s Law, it was the prophets' responsibility to announce judgment against him and potentially remove the king if need be (cf. 1 Samuel 13-14; 2 Samuel 7; 1 Kings 11:29-39).