TT #101 · Parashas Shoftim · Second Aliyah · Passuk 17:17
And he must not multiply wives for himself, so that his heart not turn away; and he must not greatly multiply silver and gold for himself.
Torah Temimah points to Sanhedrin 21b.
TT lemma: לֹא יַרְבֶּה לוֹ נָשִׁים.
English: ‘He shall not multiply wives for himself’ – one might have thought even up to the number of eighteen; therefore the Torah says ‘so that his heart not turn away.’
Derash limiting the number (Bavli) — the prohibition is calibrated by the danger of the heart turning aside.
A king may not multiply wives beyond the point that risks turning his heart away from Hashem. The limit is set to protect the king’s spiritual integrity.