And Jehoshaphat too, once he was established in the kingship, did not occupy himself with the affairs of kingship, nor with honor, but with the affairs of judgment, as it is said: "[And Jehoshaphat reigned] and he strengthened himself over Israel" (II Chronicles 17:1). What is "and he strengthened himself"? That he strengthened himself and appointed the judges. And it says: "And his heart was lifted up in the ways of the LORD; and moreover he removed the high places and the Asherim out of Judah" (II Chronicles 17:6). Now was there haughtiness of spirit in him, that it says "and his heart was lifted up"? Rather, it is that he appointed over them the judges who knew how to walk in the ways of the LORD, and they kept the way of the LORD. "And he said to the judges: See what you are doing, for you do not judge for man but for the LORD, who is with you in the matter of judgment. And now let the dread of the LORD be upon you; take heed and act, for there is no iniquity with the LORD our God, nor respect of persons, nor taking of a bribe" (II Chronicles 19:6-7). And if Moses our teacher, who was not commanded concerning the judges—rather Jethro said to him, "And you shall provide out of all the people [able men]" (Exodus 18:21)—seated a Sanhedrin for Israel, we, who have indeed been commanded in the Torah, "Judges and officers shall you appoint for yourself" (Deuteronomy 16:18), how much more so! And from where do we know that Moses seated a Sanhedrin? As it is said: "And Moses chose able men out of all Israel [and made them heads over the people]" (Exodus 18:25). And Jerusalem too was praised only on account of justice, as it is said: "And your renown went forth among the nations for your beauty" (Ezekiel 16:14). And what is this adornment (hadar)? This is justice, as it is said: "Nor shall you favor (tehdar) a poor man in his cause" (Exodus 23:3). And Jerusalem was destroyed only over the corruption of justice, as it is said: "You of the defiled name, full of tumult" (Ezekiel 22:5)—the name that you had at first through justice you have defiled. And it is written: "She that was full of justice" (Isaiah 1:21). And so Jeremiah said to them: "The kings of the earth did not believe [that an adversary or enemy would enter the gates of Jerusalem]; it was for the sins of her prophets and the iniquities of her priests [who shed the blood of the righteous in her midst]" (Lamentations 4:12-13). At that hour the Holy One, blessed be He, swore that He Himself would exact punishment from them and from the judges, as it is said: "Therefore (lakhen) says the Lord, the LORD of hosts, the Mighty One (Avir) of Israel" (Isaiah 1:24). And "therefore" (lakhen) is nothing but a term of oath, as it is said: "And therefore I have sworn to the house of Eli" (I Samuel 3:14). And "Avir" is nothing but a term for the Av Bet Din (head of the court), as it is said: "the chief (abir) of the herdsmen who belonged to Saul" (I Samuel 21:8). This teaches you that the Holy One, blessed be He, became an Av Bet Din to exact punishment from them. And from where do we know that Scripture speaks of the judges? See what is written after it: "And I will restore your judges as at the first" (Isaiah 1:26). Therefore David said: "He declares His words to Jacob [His statutes and His ordinances to Israel]" (Psalms 147:19).
Jehoshaphat, Moses, and Why Jerusalem Rose and Fell on Justice
Midrash Tanchuma Buber, Shoftim 2:1
ואף יהושפט כיון שהוחזק במלכות, לא נתעסק בעסקי מלכות, ולא בכבוד, אלא בעסקי הדין, שנאמר [וימלוך יהושפט וגו'] ויתחזק על ישראל (דה"ב יז א), מה [ויתחזק], שנתחזק ומינה את הדיינין, ואומר ויגבה לבו בדרכי ה' ועוד הסיר את הבמות ואת האשרים מיהודה (שם שם ו), וכי גסות הרוח היתה בו, שהוא אומר ויגבה לבו, אלא שמינה עליהם את הדיינין היודעים ללכת בדרכי ה', ושמרו דרך ה', ויאמר אל השופטים ראו מה אתם עושים, כי לא לאדם תשפטו כי לה' ועמכם בדבר (המשפט) [משפט], ועתה יהי פחד ה' עליכם, שמרו ועשו, כי אין עם ה' אלהינו עולה ומשוא פנים ומקח שוחד (דה"ב יט ו ז), ומה משה רבינו שלא נצטוה על הדיינין, אלא אמר לו יתרו ואתה תחזה מכל העם וגו' (שמות יח כא), הושיב סנהדרין לישראל, אנו שהרי נצטוינו בתורה שופטים ושוטרים תתן לך על אחת כמה וכמה, ומניין שהושיב משה סנהדרין, שנאמר ויבחר משה אנשי חיל מכל ישראל וגו' (שמות יח כה), ואף ירושלים לא נשתבחה אלא על ידי הדין, שנאמר ויצא לך שם בגוים (ביופיך) [ביפיך] (יחזקאל טז יד), ואיזה הוא הידור, זה הדין, שנאמר ודל לא תהדר בריבו (שמות כג ג), ולא חרבה ירושלים אלא על קלקול הדין, שנאמר טמאת השם רבת המהומה (יחזקאל כב ה), שם שהיה לך בתחילה על ידי דין טמאת, וכתיב מלאתי משפט (ישעיה א כא), וכך אמר להם ירמיה, לא האמינו מלכי ארץ [וגו'] מחטאת נביאיה עונות כהניה וגו' (איכה ד יב יג), באותה שעה נשבע הקב"ה שהוא בעצמו נפרע מהם ומהדיינין, שנאמר לכן נאם האדון ה' צבאות אביר ישראל וגו' (ישעיה א כד), ואין לכן אלא לשון שבועה, שנאמר ולכן נשבעתי לבית עלי (ש"א ג יד), ואין אביר אלא לשון אב ב"ד, שנאמר אביר הרועים אשר לשאול (שם כא ח), ללמדך שהקב"ה נעשה אב בית דין להפרע מהן, ומניין שבדיינין הכתוב מדבר, ראה מה כתיב אחריו, ואשיבה שפטיך כבראשונה (ישעיה א כו), לכך אמר דוד מגיד דבריו ליעקב (תהלים קמז יט).