Dr. Rabbi Zev Farber, "Does the Torah Really Want Us to Appoint a King?" https://www.thetorah.com/article/does-the-torah-really-want-us-to-appoint-a-king
The conditional opening [of Deuteronomy 17:14] is unusual. In all other cases, following the phrase “after you have entered the land” the Torah states a law in simple, apodictic form [when you enter... you shall observe...].
The law of the king makes the appointment of the king optional; the word וְאָמַרְתָּ (“and you say”) presents the possibility that you might say that you want a king, but does not mandate a king’s appointment. To complicate matters further, the option of appointing a king is phrased like a standard commandment: the grammatical form of שום תשים (“you shall surely set”), a cognate accusative—when the direct object is the same root as the verb—is generally a way of emphasizing a command, not an option.
The option of appointing a king is hardly phrased neutrally. Instead, the very choice to appoint a king is presented negatively, as something the Israelites might do if they decide they want to copy their non-Israelite neighbors. Throughout the Torah, copying non-Israelites is code for rebellious behavior and acting against the will of YHWH.
Isaac Abravanel, Commentary on the Pentateuch, Deuteronomy 17:14
[E]ven if we grant that the king is useful and necessary for a people in order to perfect political society and protect it, nevertheless, in regard to the Israelite people, this is not so: for them he is neither useful nor necessary. This is because kings are [presumed] necessary in a nation for three reasons: first, concerning wars, in order to rescue [the people] from their enemies and defend their land; second, in order to ordain the laws [nomoi] and lay down the doctrines needed for their perfection; and third, to administer punishment outside the law according to the needs of the hour. ...
These three things are not necessary for the Israelite nation. They do not require [a king] for wars and for deliverance from their enemies, because Israel is delivered by God and He fights for them, as it is written, "O happy Israel! Who is like you, a people delivered by the Lord, your protecting Shield, your sword triumphant! Your enemies shall come cringing before you, and you shall tread on their backs" (Deut. 33:29). Besides, their judge goes forth and leads them in wars, as with Joshua, Gideon, Samuel, and the other judges.
They also do not require a king to lay down doctrines and laws, because "Moses charged us with the Torah" (Deut. 33:4). Moreover, God commanded us: "You shall not add anything [to what I commanded you]. ... Or what great nations has laws and rules as perfect ... ?" (Deut. 4:2, 7-8). And a king of Israel has no authority to innovate anything in the Torah nor subtract from it, as written concerning him: "He will not deviate from the commandment to the right or to the left" (Deut. 17:20).
Nor is a king required in Israel to punish [criminals] ... in accordance with the needs of the hour, because God gave that authority to the Great Court, the Sanhedrin, as I explained [elsewhere]. Furthermore, God has informed us that if a judge who acts in accordance with ... just law should acquit a wrongdoer, God Himself will punish the wicked person with His great judgement, as it is written, "Keep far from a false charge; do not charge death on those who are innocent and in the right, for I will not acquit the wrongdoer" (Exod. 23:7). This means, "I will punish him for anything for which you are unable to punish him legally."
Thus, it has been explained that these three things - that is, delivering them through war, laying down laws and commandments, and determining occasional punishment outside the law - are all performed by God for His people. Therefore, God is their king, and they have no need for a [human] king for anything.
Rabbi Samson Raphael Hirsch, Devarim 17:14 (trans. Daniel Haberman), https://www.yutorah.org/_cdn/_materials/Appointing-king-546807.pdf
The mitzvah to appoint a king is held in abeyance until the need for this appointment arises, for only if the people feel this need will they properly appreciate the institutions imposed on them from without. The sense of this need can only arise for one reason: They will want to ensure the sole factor on which God’s protection and blessing depend; they will seek to make the nation be “Israel,” the people loyal to God’s Torah. Hence, there is no doubt that the addition of “like all the nations surrounding me” can be interpreted only as follows: all the nations seek to unify all their national resources for the greatest good of their own nation, which in their view consists in the development of the greatest possible power vis-à- vis the world outside. To this end they must subordinate themselves to one head of state, at whose command all the nation’s resources must be placed for this purpose.