Devarim17:15

שׂוֹם תָּשִׂים עָלֶיךָ מֶלֶךְ אֲשֶׁר יִבְחַר יְהוָה אֱלֹהֶיךָ בּוֹ מִקֶּרֶב אַחֶיךָ תָּשִׂים עָלֶיךָ מֶלֶךְ לֹא תוּכַל לָתֵת עָלֶיךָ אִישׁ נָכְרִי אֲשֶׁר לֹא־אָחִיךָ הוּא׃

you shall surely set over yourself a king whom the Eternal your Almighty will choose. From among your brothers you shall set a king over yourself. You may not put over yourself a foreigner who is not your brother.

Devarim 17:15

שׂוֹם תָּשִׂים עָלֶיךָ

Devarim / Deuteronomy 17:15 · Remez

Devarim 17:15

שׂוֹם תָּשִׂים עָלֶיךָ מֶלֶךְ אֲשֶׁר יִבְחַר יְהוָה אֱלֹהֶיךָ בּוֹ מִקֶּרֶב אַחֶיךָ תָּשִׂים עָלֶיךָ מֶלֶךְ לֹא תוּכַל לָתֵת עָלֶיךָ אִישׁ נָכְרִי אֲשֶׁר לֹא־אָחִיךָ הוּא׃

you shall surely set over yourself a king whom the Eternal your Almighty will choose. From among your brothers you shall set a king over yourself. You may not put over yourself a foreigner who is not your brother.

Remez רֶמֶז

Thirty steps

It is not enough to take a high office, one must grow into it. The commentators count the letters in the words about the king.

Kitzur Ba'al HaTurim: "you shall set over you" equals in numerical value "thirty steps": kingship is acquired by thirty qualities. "From among your brothers" equals "from the tribe of Yehudah (Judah)". Agra DeKala: the name Yehudah (יְהוּדָה) hides the Name of the Eternal. "Whom He will choose" means chosen for good, like the house of David.

How Kitzur Ba'al HaTurim and Agra DeKala explain it

Kitzur Ba'al HaTurim You shall set over you

In numerical value it equals "thirty steps" (שְׁלֹשִׁים מַעֲלוֹת). This teaches that kingship is acquired by thirty steps.

Kitzur Ba'al HaTurim From among your brothers

In numerical value it equals "from the tribe of Yehudah" (מִשֵּׁבֶט יְהוּדָה).

Agra DeKala You shall set over you a king whom the Eternal your Almighty will choose (Devarim / Deuteronomy 17:15)

That is, one in whose name the honoured Name is hidden, that is, from the tribe of Yehudah. And it says "whom He will choose" (יִבְחַר): that is, a king whom the Eternal your Almighty will choose for the future too, that is, from the family of David, to whom it was promised: "But My kindness shall not depart from him, as I took it from Shaul (Saul)" (Shmuel II / II Samuel 7:15). This is what it means: whom the Eternal your Almighty will choose even when he sins, "and I will chasten him with the rod of men" (Shmuel II / II Samuel 7:14), but He will choose him for the future. But a king from another tribe, even though the Eternal chooses him for a time, once he turns away from the Eternal, He will not choose him for the future.

Takeaway

Numerical value of the letters: שׂוֹם תָּשִׂים עָלֶיךָ = 1226, שְׁלֹשִׁים מַעֲלוֹת = 1226. מִקֶּרֶב אַחֶיךָ = 381, מִשֵּׁבֶט יְהוּדָה = 381. The count is checked.
"Kingship is acquired by thirty steps" comes from the Mishnah: kingship needs thirty qualities, priesthood twenty-four, and Torah forty-eight (Avot 6:6).
The name יְהוּדָה holds all four letters of the Name of the Eternal (י ה ו ה) and one more letter, dalet (ד). Hence Agra DeKala: the Name is hidden in the name Yehudah.
David was of the tribe of Yehudah, and Shaul of the tribe of Binyamin (Benjamin). The promise to the house of David was given through the prophet Natan (Nathan) (Shmuel II / II Samuel 7).