Dovid Hamelech calls Hashem a "Tzadik". What does that mean?? A Tzadik is someone who follows what Hashem says very well. How can Hashem HIMSELF be called Tzadik?
Digest the question.
Think of an answer.
A Tzadik is someone who uses his free choice to do what is right. Hashem used his "free choice" to reveal reflections of Himself in this world and to connect to Am Yisrael who are a nation of Tzadikim.
See what Rav Charlap writes and how he "teiches" a pasuk in Tehilim bi-ofen shel pilei plaos: