TT #115 · Parashas Shoftim · Second Aliyah · Passuk 17:20
So that his heart not be lifted above his brethren, and so that he not turn aside from the commandment to the right or to the left, in order that he may prolong days over his kingdom, he and his sons, in the midst of Yisrael.
Torah Temimah points to Sifrei Devarim 162.
TT lemma: וּלְבִלְתִּי סוּר מִן הַמִּצְוָה.
English: ‘And so that he not turn aside from the commandment to the right or to the left’ – that he not deviate from the mitzvos either to be lenient or to be stringent beyond the law.
Derash on fidelity to the law (Sifrei) — the king must neither add to nor subtract from the commandments.
The king may not turn aside from the mitzvos either to the right or to the left. He is subject to the Torah, not above it.