"and they shall judge, etc.": This refers to the appointment of judges. "and they shall judge the people": (even) against their will.
(Ibid. 19) "Do not pervert judgment": in money matters. "Do not show favoritism": in judging. Variantly: "Do not pervert judgment and do not show favoritism": Why is this stated? Is it not already written "You shall not pervert judgment" and "you shall not show favoritism"? This refers to the appointment of the judges.
Variantly: "Do not pervert judgment": Do not say: "This man is nice; this man is my kinsman."