Another interpretation: "By justice a king sustains the land" (Proverbs 29:4) — this is the Holy One, blessed be He. When He came to give the Torah to Israel, He opened with justice. What is written? "There He set for him a statute and an ordinance" (Exodus 15:25). And here Moses learned the ordinances that he taught to Israel.
How God Began the Torah with Justice at Marah
Midrash Tanchuma Buber, Mishpatim 2:2
ד"א מלך במשפט יעמיד, זה הקב"ה כשבא ליתן תורה לישראל פתח במשפט, מה כתיב, שם שם לו חוק ומשפט (שמות טו כה), וכאן למד משה את המשפטים שלמד לישראל.