The oft-quoted maxim tzedek tzedek tirdof (Deuteronomy 16:20) — usually translated as “justice, justice shall you pursue” — does not repeat the word zedek simply for effect. The real point is that society must pursue justice justly.
Here the Jewish tradition has another lesson to teach us. On one hand, the Torah repeatedly warns about injustice to the poor: “You shall not pervert judgment of the poor in his cause” (Exodus 23:6); “you shall not elevate the person of might; judge your neighbor righteously” (Leviticus 19:15). The tradition even calls for special, additional help for the poor, for the vulnerable widow and orphan, for the outsider. As Maimonides asserts: The more a person lacks, the more we are commanded to help him (Mishneh Torah, Sefer Zeraim, Hilchot Matnot Aneeyim, ch. 7, h. 3).
On the other hand, one must not pursue justice through unjust means: “You shall not favor a poor man in his cause [unjustly]” (Exodus 23:3); and “you shall not do unrighteousness in judgment [or policy]” (Leviticus 19:15).
The Torah is warning against twisting our basic moral code on behalf of the oppressed. We cannot compromise our principles to assert that the oppressed are just regardless of their behavior, simply because of their identity. Their race, gender, past colonial status, membership in a marginalized group, and so forth, do not a priori make their cause right and all opposition to it wrong.
Rabbi Yitz Greenberg, “Judaism and the Politics of Tikkun Olam“, Sapir, vol. 1 (Spring 2021), 72.