Seudah Shlishit Shoftim 5783
וְהָיָ֣ה כְשִׁבְתּ֔וֹ עַ֖ל כִּסֵּ֣א מַמְלַכְתּ֑וֹ וְכָ֨תַב ל֜וֹ אֶת־מִשְׁנֵ֨ה הַתּוֹרָ֤ה הַזֹּאת֙ עַל־סֵ֔פֶר מִלִּפְנֵ֖י הַכֹּהֲנִ֥ים הַלְוִיִּֽם׃
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.
את משנה התורה. שְׁתֵּי סִפְרֵי תוֹרָה, אַחַת שֶׁהִיא מֻנַּחַת בְּבֵית גְּנָזָיו, וְאַחַת שֶׁנִּכְנֶסֶת וְיוֹצֵאת עִמּוֹ (סנהדרין כ"א); וְאֻנְקְלוֹס תִּרְגֵּם "פַּתְשֶׁגֶן", פָּתַר משנה לְשׁוֹן שִׁנּוּן וְדִבּוּר:
את משנה התורה [HE SHALL WRITE HIM] A משנה תורה — i.e. two scrolls of the Law, one that is placed in his treasury and the other that goes out and comes in with him (i.e. a small scroll which he carries everywhere with him) (Sanhedrin 21b). Onkelos, however, renders משנה by פתשגן, a copy; he thus interpreted the word משנה in the sense of שנן, repeating and uttering.
משנה התורה - זקיני פירשו בדברי הימים: שני ספרי התורה. ותרגומו פתשגן. ואינו מגזרת ושננתם.
משנה התורה, my grandfather Rashi, explained this as meaning two separate Torah scrolls, [in line with the traditional interpretation of our sages in Sanhedrin 21, as distinct from Onkelos who derives the word משנה as related to שנן, (Deut. 6,7) to delve into the deeper meaning. Therefore,] Onkelos renders the word as פתשגן, a clearly worded interpretation, translation. [The king would have to have a version of the Torah at hand which a layman can understand without difficulty.]
אם עשה כן כדאי הוא שתתקיים כו'. דאל"כ והיה כשבתו למה לי, דהל"ל וכתב לו משנה תורה וכו', דודאי קודם לכן אינו מחויב יותר משאר ישראל. אלא שהוא מוסב אלעיל שהכתוב מבשרו שאם יעשה כן שתתקיים מלכותו:
If he fulfills this, then he is worthy of [his kingdom] enduring. Otherwise, why is [the phrase] “that when he occupies” necessary? It should have [merely] written, “He must write for himself a duplicate of this Torah, etc.,” because before this he is certainly not any more obligated [to write a Torah scroll] than other Jews. Therefore it must be connected to what is written above [and means] that the Torah is informing him that if he fulfills this [i.e. these commands], his kingdom will endure.
מתני׳ לא ירבה לו סוסים אלא כדי מרכבתו וכסף וזהב לא ירבה לו מאד אלא כדי ליתן אספניא וכותב לו ס"ת לשמו יוצא למלחמה מוציאה עמה נכנס הוא מכניסה עמו יושב בדין היא עמו מיסב היא כנגדו שנאמר (דברים יז, יט) והיתה עמו וקרא בו כל ימי חייו:
MISHNA: The king “shall not accumulate many horses for himself” (Deuteronomy 17:16), but only enough for his chariot in war and in peace. “Neither shall he greatly accumulate silver and gold for himself” (Deuteronomy 17:17), but only enough to provide his soldiers’ sustenance [aspanya]. And the king writes himself a Torah scroll for his sake, as stipulated in Deuteronomy 17:18. When he goes out to war, he brings it out with him. When he comes in from war, he brings it in with him. When he sits in judgment, it is with him. When he reclines to eat, it is opposite him, as it is stated: “And it shall be with him and he shall read it all the days of his life” (Deuteronomy 17:19).
הקודם הוא מבואר מכמה מצוות הבאות בתורה האלהית שכל אחת היא באה להרחיק האדם מאי זה גנאי ומדה פחותה כמו שתאמר מצות פריקה וטעינ' שהכוונ' לעקור ולשרש טבע השנא' מקרבנו נגד אחינו מקניהם וקניינם עד שכבר תהיה בעבור זה טעינת השונא קודמת לפריקת האוהב כמו שבא בפרשת משפטים כי כל זה בכלל לא תשנא את אחיך בלבבך וגו' (ויקרא י"ט). וכן הלואת כספים נאמר בו נתון תתן לו ולא ירע לבבך בתתך לו (דברים ט"ו) מלמד שהמצו' ההיא להרחיק צרות העין וכילות הלב מהאנשים. והקש על זה בלא תלך רכיל ולא תקום ולא תטור (ויקרא י"ט) והדומים שכלם להשיב האנשים במדותיה' הנפרדות כל אחת לפי ענינה כי על כן אמרה התור' על כללן לטוב לך (דברים י') לטוב לנו (שם ו') למען ייטב לך (שם כ"ב) כלומר שהכוונ' בהם היא להיטיב האנשים כדי שימצאו אצל כל מעשה ומעש' על צד הישר והטוב: אמנם הנמשך מה שיתחייב מזה בגזירה שכלית הכרחיית מצאנו ראינו ביאור אמתתו מקצת מצות ממנה כמו שהוא הענין בדבר המשפט כי לפי שאין הכוונ' בו להרחיק מדה אחת רעה לבד כי אם למנוע ולהרחיק חמס וריב מעיר על כל דבר פשע אשר יולד ביניהם עושק רש וגזל משפט וצדק מעניני הממונות או קלונות וחבלות הגופים והרציחות אשר המה רעים וחטאים גדולים ורבים כי כרובם וגדולתם כן החמיר' התור' מאד על זה והרחיק' הטיית הדין והמביא אליו אמר בפרשת משפטים לא תטה משפט וגו'. מדבר שקר תרחק וגו'. ושחד לא תקח וגו'. במקום אחר לא תעשו עול במשפט לא תשא פני דל וגו' (ויקרא י"ט). ובאחר שמוע בין אחיכם ושפטת צדק וגו' (דברים א'). לא תכירו פנים במשפט וגו' (שם ט"ז). ולסוף לא תטה משפט לא תכיר פנים ולא תקח שחד וגו' (שם ט"ז) הנה שבאו האזהרות רבות וחמורות כפי רוב הנזקים המתרגשים לבא מהעדר המשפט וכמו שאז"ל צדק צדק תרדוף למען תחיה וירשת את הארץ כדאי הוא מנוי הדיינים להחיות את ישראל ולהושיבם על אדמתם (ספרי פ' שופטים) והוא מבואר. ומזה המין עצמו הוא למוד התורה שאין הכוונ' להישיר האדם ולהטיבו במדה אחת או קצת מדות כי אם להסיר מסביביו כמה מכשלות ונזקים העוטרים אליו מפה ומפה ולזה רבו כמו רבו עליו המצות התמידיות וגם הטיל' המצו' על כל האדם וכל זמן עד שלא ישאר לו זמן פנוי ממנה כמ"ש הנביא לא ימוש ספר התור' הזה מפיך והגית בו יומה ולילה למען תשמור ככל הכתוב בו וגו' (יהושע א'). ובמלך והיתה עמו וקרא בו כל ימי חייו למען ילמד לירא' את ה' אלהיו לשמור את כל דברי התורה הזאת וגו' (דברים י"ז) כי להיות המלך איש שהכל תלוי בו והטוב והרע הנמצאת בו אינו טוב או רע חלקי ופרטי אבל כללי הנה הרבה עליו תורה ומצות בצוותו לכתוב את ספר משנה התור' ולקבוע למודו בה תמיד להקריב הטוב הכללי הבא לרגלו ולהרחיק ולמנוע הרעות הרבות הגדולות והנזקים הנפלאים המתחייבים מהפכו. וכבר קרה בשמירתו בזה יותר משאר האנשים מה שיקרה בשמירתו בסבות המלחמות כי הנה לכל איש מאנשי הצבא יספיק שיבאו שמה איש וכליו בידו להדיח מעליו סכנת המנגד אמנם המלך ישתדלו שלא יצא עמהם אבל שיהיה במקום המשומר מכל פגע כמו שאמרו עבדי דוד אליו זה פעמים וכאשר כתבנו בשער ע"ח ואם א"א לו שלא לצאת תהיה ביאתו לשם היותר בטוח' שאפשר בהיות כל גבוריו סביבו שומרים לראשו וכל שרי חייליו מימינו ומשמאלו ולפניו אין מספר לנדודיו וכל זה למה לפי שנפילת המלך לא תהיה נפילה חלקית מאיש אחד אבל נפילת העם כלו וכן הוא הענין בשמירת המלך המצוה והתור' או עוברו עליה וזה מה שנתאמת מאד בספורי המלכים אשר מלכו על ישראל ויהודה כל הימים כי בכלם נתקיים מה שאז"ל דור לפי פרנס (ערכין י"ז.):
The Torah demands on repeated occasions that we rid ourselves of negative virtues such as hatred, jealousy and the like. Not only are we commanded "do not hate your brother in your heart," (Leviticus 19,17) but we are even commanded to physically assist our enemies in loading or unloading his donkey, should the occasion demand it. We are asked to lend or to give alms repeatedly to the same people even, and to avoid doing so out of a feeling of distaste for such beggars. All this is designed to refine our character. We must not bear tales, avenge unneighbourly behaviour, and similar commandments. The Torah states as the general purpose of the legislation "so it will be good for you; so you will be well off; so it will be good for us." In other words, those who perform these mitzvot will refine their character by doing so. Not only will one merit external benefits from the performance of such social commandments, i.e. reward, but there will be an additional benefit for us, the improvement of our personality. Whenever the Torah considers a particular commandment of special importance, it repeats the demand to observe such a mitzvah. Sometimes the demand is repeated even more than twice. We are told "do not pervert justice, listen to both sides when sitting in judgment, do not give preferential treatment to either rich or poor, pursue justice with fairness." The greater the negative impact if one should fail to observe certain commandments, the greater the emphasis the Torah places on its observance. In fact, inheritance of the land of Israel is made conditional on the observance of these social statutes. Study of Torah is one of the categories of mitzvot that are the foundation of personal and national well being. This is so, since it not only leads to the development of positive virtues, but also helps us avoid the many pitfalls man is exposed to. For that reason, the mitzvah of Torah study is not like kan tzippor, something to be observed if it happens our way, yet not something that needs to be sought out, but it is a duty incumbent upon each of us at all times, and applies practically within any environment we may find ourselves in. It is immaterial whether a person is highly placed or in very modest circumstances. Joshua (Joshua 1,8) is commanded to have access to a sefer Torah, Torah scroll at all times. Kings are to write it and study it. (Deut. 17,18) History shows that whenever a Jewish king treated Torah as a most precious possession and source of inspiration, so did his people. On the other hand, as soon as the king ignored the Torah, the people were not long in following suit. The result was usually disastrous and not too long in coming. The reason the king is elected as a model for how to treat Torah, is simply that the king's safety is symbolic of the security of the entire nation. When the aging David could not longer actively participate in battle without endangering his life unduly, his generals were most concerned to keep him in a safe place, pointing out that his personal safety was the key to the nation's success in battle, and to the maintenance of morale among the population. (Samuel II chapter 8) The Talmud in Erchin 17, states "each generation according to its leaders." The meaning is that the fate of the generations is in large measure due to the actions of its leaders.
וְהָיְתָ֣ה עִמּ֔וֹ וְקָ֥רָא ב֖וֹ כׇּל־יְמֵ֣י חַיָּ֑יו לְמַ֣עַן יִלְמַ֗ד לְיִרְאָה֙ אֶת־יְהֹוָ֣ה אֱלֹהָ֔יו לִ֠שְׁמֹ֠ר אֶֽת־כׇּל־דִּבְרֵ֞י הַתּוֹרָ֥ה הַזֹּ֛את וְאֶת־הַחֻקִּ֥ים הָאֵ֖לֶּה לַעֲשֹׂתָֽם׃ לְבִלְתִּ֤י רוּם־לְבָבוֹ֙ מֵֽאֶחָ֔יו וּלְבִלְתִּ֛י ס֥וּר מִן־הַמִּצְוָ֖ה יָמִ֣ין וּשְׂמֹ֑אול לְמַ֩עַן֩ יַאֲרִ֨יךְ יָמִ֧ים עַל־מַמְלַכְתּ֛וֹ ה֥וּא וּבָנָ֖יו בְּקֶ֥רֶב יִשְׂרָאֵֽל׃ {ס}
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. 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.

R' Avraham Shmuel Binyamin Schreiber, the Ketav Sofer (1815-1871, Hungary), says every king, leader or rabbi should have two Sefer Torahs - one for "home," for himself, with which he should observe every mitsva with strict precision (בזהירות ובדקדקנות); and the other to take with him to the people, with which he shows more latitude, teaching them more according to the "spirit of the law" (לפנים משורת הדין).