The command to appoint judges follows on from the previous sedra which discussed the three pilgrimage festivals. Ibn Ezra explained that Jews coming to Jerusalem would see the quality of the assembled scholars and appreciate how many were competent to decide important legal cases and religious questions. Nevertheless, Jews were commanded to appoint qualified people from their own villages to judge them.
R’ Elie Munk quotes a midrash which had King David being consoled after being told by the prophet Nathan to let his son Solomon have the privilege of building the Temple. The midrash stated that G-d said to David that “the justice that you carry out is dearer to My heart than the Temple”. (Tzedek – justice, righteousness). David could convince the guilty party of his culpability who would then be happy to compensate the person he had wronged. King Solomon stated that “to do of righteousness and justice is more acceptable to G-d than sacrifice”.
R’ Munk goes on to write that “the forces of law and order in the country are not there to ensure that some definite political order is imposed, but to be the servants of justice”. Judgement should be tinged with mercy, looking for extenuating circumstances. It should also be neutral and un-biased. No bribes should be taken, as they “blind the eyes of the wise and make just words crooked”.
The Torah then states “Tzedek, tzedek, tirdof”-righteousness, righteousness shall you pursue. R’ Munk explains that the repetition means not only that justice must be done, but it must also achieved in a just way.