Once you have entered the land the LORD your God is giving you and you have taken possession of it and settled down in it, you might say: "Let's appoint a king over us, as all our neighboring nations have done."
You can indeed appoint over you a king that the LORD your God selects. You can appoint over you a king who is one of your fellow Israelites. You are not allowed to appoint over you a foreigner who is not one of your fellow Israelites.
That granted, the king must not acquire too many horses, and he must not return the people to Egypt in order to acquire more horses, because the LORD told you: "You will never go back by that road again."
The king must not take numerous wives so that his heart doesn't go astray. Nor can the king acquire too much silver and gold.
Instead, when he sits on his royal throne, he himself must write a copy of this Instruction on a scroll in the presence of the levitical priests.
That Instruction must remain with him, and he must read in it every day of his life so that he learns to revere the LORD his God by keeping all the words of this Instruction and these regulations, by doing them,
by not being overbearing toward his fellow Israelites, and by not deviating even a bit from the commandment. If the king does all that, he will ensure lasting rule in Israel for himself and for his successors.