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 · Sod

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.

Sod סוֹד

The king is the heart

Something rules inside each of us: kindness, fear, anger. This verse can be read about whom to crown within yourself.

Mei HaShiloach: a king "from among your brothers" is one whose heart is good to all, like David, who pitied his sheep. "The foreigner" is a man of anger: anger has no share in Israel. Ba'al Shem Tov: the king in Israel is the heart, and the heart "hears", that is, understands.

How Mei HaShiloach and Ba'al Shem Tov explain it

Mei HaShiloach From among your brothers you shall set a king over you

That is, that his heart be good to all Israel. As we find with King David, peace be upon him, of whom it says: "And took him from the sheepfolds" (Tehillim / Psalms 78:70). That is, the Holy One, blessed is He, saw how compassionately he treated his sheep, and set him as king over Israel.

Mei HaShiloach You may not set a foreigner over you

That is, one who has anger in him, for the trait of anger has no share in Israel.

Ba'al Shem Tov You shall set a king over you and so on, from among your brothers you shall set a king over you and so on

I heard from my master, my grandfather, of blessed memory, that the king in Israel is the heart of Israel. And by this he explained the verse: "How can I go? Shaul (Saul) will hear and kill me" (Shmuel I / I Samuel 16:2). He asked: why was Shmuel (Samuel) afraid precisely of going? One can go in silence. He should rather have said: how shall I return, once I anoint another as king, and Shaul will kill me. And he explained: the king is the heart of all Israel, and the heart "hears", that is, understands. That is the meaning of: "How can I go? Shaul will hear." For until David is anointed, Shaul is still king of Israel, and "will hear" means: will understand why I go, for what reason, "and kill me". But he was not afraid of returning: David would already be anointed king, and Shaul would not understand and not hear, for surely the thing would be done in secret (Degel Machaneh Ephraim, portion Vaetchanan).

Takeaway

"And took him from the sheepfolds": David was a shepherd before he became king (Tehillim / Psalms 78:70–71). Mei HaShiloach sees in his care for the sheep the reason he was chosen.
"My master, my grandfather" is the Ba'al Shem Tov. His words are passed on by his grandson, the author of Degel Machaneh Ephraim.
Shmuel went to anoint David while Shaul was still king (Shmuel I / I Samuel 16). The Ba'al Shem Tov explains his fear: while Shaul is king, he is the heart of the people and senses what is happening.
On the Drash level the people told Agrippa "you are our brother". Mei HaShiloach explains who is a brother at heart: one whose heart is good to all.