Alternatively, our verse addresses the people who are subject to litigation and exhorts them to strive for righteousness regardless of whether this will be financially beneficial or harmful to them. This is why the Torah repeats the exhortation.
צדק צדק תרדוף. שאין חקר וסוף לבחי' צדק ואמת. כי ה' אלקים אמת. ולכך לעולם יש להוסיף ולהעמיק שיהי' אמת לאמיתו. כי אינו אמת עד שנעשה כל האדם אחד מיוחד לעבודתו ית' ואמת מראש עד סוף אותיות התורה. בשם הרב הק' מפרשיסחא היהודי ז"ל להיות רדיפת הצדק. בצדק לא בשקר. ודפח"ח:
"Justice, justice, you shall pursue." [The repetition of the word tzedek comes to teach that] there is no end to His righteousness and truth, for G-d is true. Therefore, it is incumbent upon one to always delve deeper to insure that he is [living according to] complete truth. Truth can only be reached when one becomes entirely united in his service of G-d, and is completely true in all the letters of the Torah.
Another explanation [for the repetition], in the name of the Yid HaKadosh from Psishcha: One must pursue justice with justice itself, and not falsehood. And the words of the wise are gracious.
The reason why the word tzedek is repeated is as follows: The first tzedek refers to how G-d punctiliously watches our conduct. The second refers to us; that is, when we see a friend, G-d forbid, transgressing the Torah, and you feel angry [for the desecration of the Torah, ed.], the Torah tells us "tzedek!" -- namely, that Hashem does not want you to prosecute your friend! As I wrote earlier, it is akin to how the Sanhedrin would not carry out punishment immediately after judgment had been rendered -- even if they knew they had ruled correctly -- for perhaps Hashem would illuminate their eyes and open a new light by way of which the judges could find a zechus for a Jewish person [i.e., the one was had been judged for punishment, ed.].
לקוטי לוי יצחק ואתחנן ע' תנא
צדק צדק תרדוף, צדק עליון וצדק תחתון.
Rabbi Levi Yitzchak Schneerson
The repetition of the word "Tzedek" (justice) refers to an upper tzedek and a lower tzedek.