The injunction in Ex 23:2, "do not show favoritism to a poor", should be balanced by another instruction in V6, "You shall not deny justice to the poor".
Ellicott summarizes the situation well -
(3) Neither shalt thou countenance a poor man in his cause.—We must
not “pervert judgment” either in favour of the rich or of the poor.
Justice must hold her scales even, and be proof equally against a
paltry fear of the rich and a weak compassion for the indigent. The
cause alone is to be considered, not the persons. (Comp. Leviticus
Similarly, the Pulpit commentary says this -
Verse 3. - Neither shalt thou countenance a poor man in his cause.
After the many precepts in favour of the poor, this injunction
produces a sort of shock. But it is to be understood as simply
forbidding any undue favouring of the poor because they are poor, and
so as equivalent to the precept in Leviticus 19:15, "Thou shalt not
respect the person of the poor." In courts of justice, strict justice
is to be rendered, without any leaning either towards the rich, or
towards the poor. To lean either way is to pervert judgment. Exodus