Monarchical Necessity
(יד) כִּֽי־תָבֹ֣א אֶל־הָאָ֗רֶץ אֲשֶׁ֨ר יְהֹוָ֤ה אֱלֹהֶ֙יךָ֙ נֹתֵ֣ן לָ֔ךְ וִֽירִשְׁתָּ֖הּ וְיָשַׁ֣בְתָּה בָּ֑הּ וְאָמַרְתָּ֗ אָשִׂ֤ימָה עָלַי֙ מֶ֔לֶךְ כְּכׇל־הַגּוֹיִ֖ם אֲשֶׁ֥ר סְבִיבֹתָֽי׃ (טו) שׂ֣וֹם תָּשִׂ֤ים עָלֶ֙יךָ֙ מֶ֔לֶךְ אֲשֶׁ֥ר יִבְחַ֛ר יְהֹוָ֥ה אֱלֹהֶ֖יךָ בּ֑וֹ מִקֶּ֣רֶב אַחֶ֗יךָ תָּשִׂ֤ים עָלֶ֙יךָ֙ מֶ֔לֶךְ לֹ֣א תוּכַ֗ל לָתֵ֤ת עָלֶ֙יךָ֙ אִ֣ישׁ נׇכְרִ֔י אֲשֶׁ֥ר לֹֽא־אָחִ֖יךָ הֽוּא׃ (טז) רַק֮ לֹא־יַרְבֶּה־לּ֣וֹ סוּסִים֒ וְלֹֽא־יָשִׁ֤יב אֶת־הָעָם֙ מִצְרַ֔יְמָה לְמַ֖עַן הַרְבּ֣וֹת ס֑וּס וַֽיהֹוָה֙ אָמַ֣ר לָכֶ֔ם לֹ֣א תֹסִפ֗וּן לָשׁ֛וּב בַּדֶּ֥רֶךְ הַזֶּ֖ה עֽוֹד׃ (יז) וְלֹ֤א יַרְבֶּה־לּוֹ֙ נָשִׁ֔ים וְלֹ֥א יָס֖וּר לְבָב֑וֹ וְכֶ֣סֶף וְזָהָ֔ב לֹ֥א יַרְבֶּה־לּ֖וֹ מְאֹֽד׃ (יח) וְהָיָ֣ה כְשִׁבְתּ֔וֹ עַ֖ל כִּסֵּ֣א מַמְלַכְתּ֑וֹ וְכָ֨תַב ל֜וֹ אֶת־מִשְׁנֵ֨ה הַתּוֹרָ֤ה הַזֹּאת֙ עַל־סֵ֔פֶר מִלִּפְנֵ֖י הַכֹּהֲנִ֥ים הַלְוִיִּֽם׃ (יט) וְהָיְתָ֣ה עִמּ֔וֹ וְקָ֥רָא ב֖וֹ כׇּל־יְמֵ֣י חַיָּ֑יו לְמַ֣עַן יִלְמַ֗ד לְיִרְאָה֙ אֶת־יְהֹוָ֣ה אֱלֹהָ֔יו לִ֠שְׁמֹ֠ר אֶֽת־כׇּל־דִּבְרֵ֞י הַתּוֹרָ֥ה הַזֹּ֛את וְאֶת־הַחֻקִּ֥ים הָאֵ֖לֶּה לַעֲשֹׂתָֽם׃ (כ) לְבִלְתִּ֤י רוּם־לְבָבוֹ֙ מֵֽאֶחָ֔יו וּלְבִלְתִּ֛י ס֥וּר מִן־הַמִּצְוָ֖ה יָמִ֣ין וּשְׂמֹ֑אול לְמַ֩עַן֩ יַאֲרִ֨יךְ יָמִ֧ים עַל־מַמְלַכְתּ֛וֹ ה֥וּא וּבָנָ֖יו בְּקֶ֥רֶב יִשְׂרָאֵֽל׃ {ס}
(14) If, after you have entered the land that your God יהוה has assigned to you, and taken possession of it and settled in it, you decide, “I will set a king over me, as do all the nations about me,” (15) you shall be free to set a king over yourself, one chosen by your God יהוה. Be sure to set as king over yourself one of your own people; you must not set a foreigner over you, one who is not your kin. (16) Moreover, he shall not keep many horses or send people back to Egypt to add to his horses, since יהוה has warned you, “You must not go back that way again.” (17) And he shall not have many wives, lest his heart go astray; nor shall he amass silver and gold to excess. (18) When he is seated on his royal throne, he shall have a copy of this Teaching written for him on a scroll by the levitical priests. (19) Let it remain with him and let him read in it all his life, so that he may learn to revere his God יהוה, to observe faithfully every word of this Teaching as well as these laws. (20) Thus he will not act haughtily toward his fellows or deviate from the Instruction to the right or to the left, to the end that he and his descendants may reign long in the midst of Israel.
וכן היה רבי יהודה אומר ג' מצות נצטוו ישראל בכניסתן לארץ להעמיד להם מלך ולהכרית זרעו של עמלק ולבנות להם בית הבחירה
The baraita continues: And so would Rabbi Yehuda say: Three mitzvot were commanded to the Jewish people upon their entrance into Eretz Yisrael, which apply only in Eretz Yisrael: They were commanded to establish a king for themselves (see Deuteronomy 17:14–15), and to cut off the seed of Amalek in war (see Deuteronomy 25:17–19), and to build the Chosen House, i.e., the Temple, in Jerusalem (see Deuteronomy 12:10–12).

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.