Whenever a Sanhedrin, a king, or an exilarch appoints a judge who is not fitting and/or is not learned in the wisdom of the Torah and is not suitable to be a judge - even if he is entirely a delight and possesses other positive qualities - the person who appoints him violates a negative commandment, as Deuteronomy 1:17 states: "Do not show favoritism in judgment." According to the Oral Tradition, we learned that this command is addressed to those who appoint judges.
Our Sages declare: "Perhaps a person will say: 'So and so is attractive, I will appoint him as a judge,' 'So and so is strong, I will appoint him as a judge,' 'So and so is my relative, I will appoint him as a judge,' or "So and so knows all the languages, I will appoint him as a judge.' This will lead to those who are liable being vindicated and those who should be vindicated held liable, not because the judge is wicked, but because he does not know Torah law. Therefore the Torah states: "Do not show favoritism in judgment."
Our Sages also declare: "Whoever appoints a judge who is not appropriate for the Jewish people is considered as if he erected a monument, as implied by Deuteronomy 16:22: "Do not erect a monument which is hated by God, your Lord." If he is appointed instead of a Torah scholar, it is as if one planted an asherah, as Ibid.:21 states: "Do not plant an asherah or any other tree next to God's altar."
And our Sages interpreted Exodus 20:20: "Do not make gods of silver and gods of gold together with Me" to mean "Do not appoint a judge because of silver and gold." This refers to a judge who was appointed because of his wealth alone.