The Medrash (Rabbah 30:17) connects two pesukim to this one. It is stated in Yeshaya: “Thus says Hashem: Guard judgment and do tzedakah.” It is stated in Tehillim (119:121): “I performed justice and righteousness; do not leave me to my oppressors.”
Sefer Kedushas Yomtov explains the connection between the three pesukim by quoting Sefarim Hakedoshim (see introduction to Derech Pekudecha) on the verse (Yirmiyahu 4:3): “Plow for yourself a ditch, and do not plant upon thorns.” They explain that just like a farmer must clean a field because he can plow and plant it, so too before one performs a mitzvah, he must cleanse himself from sin. If one does not do so, he is “plowing on thorns”, meaning that the forces of evil will grab ahold of his mitzvah and take it for themselves.
The best way to rectify oneself before doing a mitzvah is to “redeem his sins through tzedakah (Daniel 4:24).” By giving tzedakah, one cleanses himself so that his mitzvah is pure and cannot be grabbed by the evil forces. This explains why the Arizal (Shaar Hakavanos, Tefilas Shacharis, Drush 1) says that one should give tzedakah before davening. It also explains the words of Rav Eliezer (Bava Basra 10A) that one should give a coin to charity before prayer. This tzedakah allows the prayers to ascend on high, without being obstructed by the evil forces.
Accordingly, the pasuk in Yeshaya says to “guard mishpat”, meaning that one should protect and observe the laws of the Torah. However, before one does so, he must “do tzedakah” and thereby cleanse himself from his sins so that his mitzvah is pure and can be accepted.
This also explains the pasuk in Tehillim that says that he “did mishpat”, i.e., the laws of the Torah, and “tzedek”, meaning that he first gave tzedakah. Therefore, he was not “left over for the oppressors”, meaning that evil forces were unable to steal his mitzvah.
In our Parshah, Hashem tells Moshe Rabenu that He has placed His mishpatim before Klal Yisroel for them to observe His laws. However, as the Medrash says, before one can observe the laws, he must “do tzedakah” so that his mitzvos are clean and pure and can ascend to provide a nachas ruach for Hashem.
