You shall appoint magistrates and officials for your tribes, in all the settlements that the LORD your God is giving you, and they shall govern the people with due justice.
With the help of Heaven we are going to try and explain this question. First we have to know the answer to the question of what is the purpose of the completely holy soul, which is carved out from the Throne itself of HaShem, which benefits from the radiance of the Divine Presence, to be cast down to this physical world, which is a place of danger for the soul which has to dwell inside of a body which is inclined towards sin.
To answer this second question we are going to see the commentary of the Medrash Shmuel on the following Mishnah -
רַבָּן יוֹחָנָן בֶּן זַכַּאי קִבֵּל מֵהִלֵּל וּמִשַּׁמָּאי. הוּא הָיָה אוֹמֵר, אִם לָמַדְתָּ תוֹרָה הַרְבֵּה, אַל תַּחֲזִיק טוֹבָה לְעַצְמְךָ, כִּי לְכָךְ נוֹצָרְתָּ.
Rabban Yohanan ben Zakkai received [the oral tradition] from Hillel and Shammai.He used to say: if you have learned much Torah, do not claim credit for yourself, because for such a purpose were you created.
And we actually see a source for this from Avraham and Sarah -
The below Medrash asks an amazing question on this to prove the point.
The souls they made in Charan. Rebbe Eliezer Bar Zimra. If all the people of the world got together to make even a simple mosquito, they would not have success in placing a soul within in.. but now the verse here says the souls that Avraham made in Charan? (how could a human make a soul!).. Rather these were the converts that Avraham made. OK, if they converted why does it use the wording 'souls they made', it should have just said the people he converted. Rather, this comes to teach us that whoever brings an idol worshiper closer to Torah and converts him, it's as if this convert was created from new, a completely new creation. In regards to why it says they made if it was only Avraham? Rav Huna says that Avraham would convert the men and Sarah his wife would convert the women.
This concept actually can work well to shed light on a unique teaching from the sages
אמר רב יהודה אמר רב כל המונע הלכה מפי תלמיד כאילו גוזלו מנחלת אבותיו שנאמר (דברים לג, ד) תורה צוה לנו משה מורשה קהילת יעקב מורשה היא לכל ישראל מששת ימי בראשית
Rav Yehuda says that Rav says: With regard to anyone who withholds halakha from being studied by the mouth of a student who seeks to study Torah, it is as though he robs him of the inheritance of his ancestors, as it is stated: “Moses commanded us the Torah, an inheritance of the congregation of Jacob” (Deuteronomy 33:4), indicating that the Torah is an inheritance for all of the Jewish people from the six days of Creation.
This concept can also be seen in Tractate Pesachim -
Rav Yosef added: And I heard that they (Angels) were saying in that world (Heaven): Praiseworthy is the one who arrives here with his studies in hand.
On this notion we can explain another verse from our Parsha -
This man who returns home is really returning from fear of his sin, so the Torah gave him a way out that doesn't embarrass him to say because of the sins in his hand he is leaving, so he plants a vineyard or buys a home, ect.
על מנת שאני צדיק אפילו רשע גמור מקודשת שמא הרהר תשובה בדעתו
If one says to a woman: Be betrothed to me on the condition that I am a righteous man, then even if he was a completely wicked man she is betrothed, as perhaps in the meantime he had thoughts of repentance in his mind and is now righteous.
This also explains the verse from the Prophet Hoshea..
Return, O Israel, to the LORD your God, For you have fallen because of your sin.
Take words for yourselves, And return to the LORD. Say to Him: “Forgive all guilt And accept what is good; Instead of bulls we will pay [The offering of] our lips.