Summer Sources: Judgement
(כ) כִּ֣י אָדָ֔ם אֵ֥ין צַדִּ֖יק בָּאָ֑רֶץ אֲשֶׁ֥ר יַעֲשֶׂה־טּ֖וֹב וְלֹ֥א יֶחֱטָֽא׃
(20) For there is not one good man on earth who does what is best and doesn’t err.
(טו) לֹא־תַעֲשׂ֥וּ עָ֙וֶל֙ בַּמִּשְׁפָּ֔ט לֹא־תִשָּׂ֣א פְנֵי־דָ֔ל וְלֹ֥א תֶהְדַּ֖ר פְּנֵ֣י גָד֑וֹל בְּצֶ֖דֶק תִּשְׁפֹּ֥ט עֲמִיתֶֽךָ׃

(15) You shall not render an unfair decision: do not favor the poor or show deference to the rich; judge your kinsman fairly.

(ו) יְהוֹשֻׁעַ בֶּן פְּרַחְיָה וְנִתַּאי הָאַרְבֵּלִי קִבְּלוּ מֵהֶם. יְהוֹשֻׁעַ בֶּן פְּרַחְיָה אוֹמֵר, עֲשֵׂה לְךָ רַב, וּקְנֵה לְךָ חָבֵר, וֶהֱוֵי דָן אֶת כָּל הָאָדָם לְכַף זְכוּת:

(6) Yehoshua ben Perachiah and Nitai of Arbel received from them. Yehoshua ben Perachia says, "Make for yourself a mentor, acquire for yourself a friend and judge every person favorably."

(ד) ...וְאַל תָּדִין אֶת חֲבֵרְךָ עַד שֶׁתַּגִּיעַ לִמְקוֹמוֹ...

(4) ...Do not judge your fellow until you come to his place...

(ה) ואל תדין את חברך עד שתגיע למקומו. אם ראית חברך שבא לידי נסיון ונכשל, אל תדינהו לחובה עד שתגיע לידי נסיון כמותו ותנצל:

(5) "Do not judge your fellow until you come to his place": If you see your fellow come to a test and fail, do not judge him unfavorably until a test like it comes to you and you overcome [it].

ת"ר הדן חבירו לכף זכות דנין אותו לזכות

The Sages taught in a baraita: One who judges another favorably is himself judged favorably...

(ב)... גם במה שאמרנו שכל אדם חיב לדון חברו לכף זכות, שהוא בכלל המצוה, יהיה סבה להיות בין אנשים שלום ורעות, ונמצא שעקר כל כונת המצוה להועיל בישוב בני אדם עם ישר הדין ולתת ביניהם שלום עם סלוק החשד איש באיש.

...Also, what the (rabbis) stated that each person is required to judge his/her friend favorably...promotes peace and friendship and therefore, the purpose of this mitzvah (the mitzvah to judge righteously) is to improve society with a sense of righteousness and provide peace by removing suspicion from one another.