Rambam presents the 'golden mean' — that virtue lies between extremes. Applied to justice and mercy, neither pure harshness nor boundless permissiveness is ideal; the righteous person walks the middle path, dispensing justice tempered by wisdom and compassion.
הַדֶּרֶךְ הַיְשָׁרָה הִיא מִדָּה בֵּינוֹנִית שֶׁבְּכָל דֵּעָה וְדֵעָה מִכָּל הַדֵּעוֹת שֶׁיֵּשׁ לוֹ לָאָדָם. וְהִיא הַדֵּעָה שֶׁהִיא רְחוֹקָה מִשְּׁתֵּי הַקְּצָווֹת רִחוּק שָׁוֶה וְאֵינָהּ קְרוֹבָה לֹא לָזוֹ וְלֹא לָזוֹ. לְפִיכָךְ צִוּוּ חֲכָמִים הָרִאשׁוֹנִים שֶׁיְּהֵא אָדָם שָׁם דֵּעוֹתָיו תָּמִיד וּמְשַׁעֵר אוֹתָם וּמְכַוִּן אוֹתָם בַּדֶּרֶךְ הָאֶמְצָעִית כְּדֵי שֶׁיְּהֵא שָׁלֵם בְּגוּפוֹ. כֵּיצַד. לֹא יְהֵא בַּעַל חֵמָה נוֹחַ לִכְעֹס וְלֹא כְּמֵת שֶׁאֵינוֹ מַרְגִּישׁ אֶלָּא בֵּינוֹנִי. לֹא יִכְעֹס אֶלָּא עַל דָּבָר גָּדוֹל שֶׁרָאוּי לִכְעֹס עָלָיו כְּדֵי שֶׁלֹּא יֵעָשֶׂה כַּיּוֹצֵא בּוֹ פַּעַם אַחֶרֶת. וְכֵן לֹא יִתְאַוֶּה אֶלָּא לִדְבָרִים שֶׁהַגּוּף צָרִיךְ לָהֶן וְאִי אֶפְשָׁר לִהְיוֹת בְּזוּלָתָן כָּעִנְיָן שֶׁנֶּאֱמַר (משלי יג כה) "צַדִּיק אֹכֵל לְשֹׂבַע נַפְשׁוֹ". וְכֵן לֹא יִהְיֶה עָמֵל בְּעִסְקוֹ אֶלָּא לְהַשִּׂיג דָּבָר שֶׁצָּרִיךְ לוֹ לְחַיֵּי שָׁעָה כָּעִנְיָן שֶׁנֶּאֱמַר (תהילים לז טז) "טוֹב מְעַט לַצַּדִּיק". וְלֹא יִקְפֹּץ יָדוֹ בְּיוֹתֵר. וְלֹא יְפַזֵּר מָמוֹנוֹ אֶלָּא נוֹתֵן צְדָקָה כְּפִי מִסַּת יָדוֹ וּמַלְוֶה כָּרָאוּי לְמִי שֶׁצָּרִיךְ. וְלֹא יְהֵא מְהוֹלֵל וְשׂוֹחֵק וְלֹא עָצֵב וְאוֹנֵן אֶלָּא שָׂמֵחַ כָּל יָמָיו בְּנַחַת בְּסֵבֶר פָּנִים יָפוֹת. וְכֵן שְׁאָר דֵּעוֹתָיו. וְדֶרֶךְ זוֹ הִיא דֶּרֶךְ הַחֲכָמִים. כָּל אָדָם שֶׁדֵּעוֹתָיו דֵּעוֹת (בֵּינוֹנִית) [בֵּינוֹנִיּוֹת] מְמֻצָּעוֹת נִקְרָא חָכָם: וּמִי שֶׁהוּא מְדַקְדֵּק עַל עַצְמוֹ בְּיוֹתֵר וְיִתְרַחֵק מִדֵּעָה בֵּינוֹנִית מְעַט לְצַד זֶה אוֹ לְצַד זֶה נִקְרָא חָסִיד. כֵּיצַד. מִי שֶׁיִּתְרַחֵק מִגֹּבַהּ הַלֵּב עַד הַקָּצֶה הָאַחֲרוֹן וְיִהְיֶה שְׁפַל רוּחַ בְּיוֹתֵר נִקְרָא חָסִיד וְזוֹ הִיא מִדַּת חֲסִידוּת. וְאִם נִתְרַחֵק עַד הָאֶמְצַע בִּלְבַד וְיִהְיֶה עָנָו נִקְרָא חָכָם וְזוֹ הִיא מִדַּת חָכְמָה. וְעַל דֶּרֶךְ זוֹ שְׁאָר כָּל הַדֵּעוֹת. וַחֲסִידִים הָרִאשׁוֹנִים הָיוּ מַטִּין דֵּעוֹת שֶׁלָּהֶן מִדֶּרֶךְ הָאֶמְצָעִית כְּנֶגֶד שְׁתֵּי הַקְּצָווֹת. יֵשׁ דֵּעָה שֶׁמַּטִּין אוֹתָהּ כְּנֶגֶד הַקָּצֶה הָאַחֲרוֹן וְיֵשׁ דֵּעָה שֶׁמַּטִּין אוֹתָהּ כְּנֶגֶד הַקָּצֶה הָרִאשׁוֹן. וְזֶהוּ לִפְנִים מִשּׁוּרַת הַדִּין. וּמְצֻוִּין אָנוּ לָלֶכֶת בַּדְּרָכִים הָאֵלּוּ הַבֵּינוֹנִים וְהֵם הַדְּרָכִים הַטּוֹבִים וְהַיְשָׁרִים שֶׁנֶּאֱמַר (דברים כח ט) "וְהָלַכְתָּ בִּדְרָכָיו":
The straight path: This [involves discovering] the midpoint temperament of each and every trait that man possesses [within his personality.] This refers to the trait which is equidistant from either of the extremes, without being close to either of them. Therefore, the early Sages instructed a man to evaluate his traits, to calculate them and to direct them along the middle path, so that he will be sound {of body}. For example: he should not be wrathful, easily angered; nor be like the dead, without feeling, rather he should [adopt] an intermediate course; i.e., he should display anger only when the matter is serious enough to warrant it, in order to prevent the matter from recurring. Similarly, he should not desire anything other than that which the body needs and cannot exist without, as [Proverbs 13:25] states: "The righteous man eats to satisfy his soul." Also, he shall not labor in his business except to gain what he needs for immediate use, as [Psalms 37:16] states: "A little is good for the righteous man." He should not be overly stingy nor spread his money about, but he should give charity according to his capacity and lend to the needy as is fitting. He should not be overly elated and laugh [excessively], nor be sad and depressed in spirit. Rather, he should be quietly happy at all times, with a friendly countenance. The same applies with regard to his other traits. This path is the path of the wise. Every man whose traits are intermediate and equally balanced can be called a "wise man." A person who carefully [examines] his [behavior], and therefore deviates slightly from the mean to either side is called pious. What is implied? One who shuns pride and turns to the other extreme and carries himself lowly is called pious. This is the quality of piety. However, if he separates himself [from pride] only to the extent that he reaches the mean and displays humility, he is called wise. This is the quality of wisdom. The same applies with regard to other character traits. The pious of the early generations would bend their temperaments from the intermediate path towards [either of] the two extremes. For some traits they would veer towards the final extreme, for others, towards the first extreme. This is referred to as [behavior] beyond the measure of the law. We are commanded to walk in these intermediate paths - and they are good and straight paths - as [Deuteronomy 28:9] states: "And you shall walk in His ways."