Another interpretation of "Avenge the vengeance of the children of Israel" (Numbers 31:2). This is what Scripture says: "He does not withdraw His eyes from the righteous" (Job 36:7). What is the meaning of "He does not withdraw His eyes from the righteous"? The Holy One, blessed be He, does not withhold from the righteous what he desires to see with his own eyes. This teaches that Moses longed to see the vengeance upon the Midianites before he died. And concerning him it is said: "The righteous one will rejoice when he beholds vengeance" (Psalms 58:11). "The righteous one will rejoice" — this is Moses. "When he beholds vengeance" — the vengeance of Midian. "He will bathe his feet in the blood of the wicked one" (ibid.) — this is Balaam.
Why Moses Longed to See Vengeance on Midian Before His Death
Midrash Tanchuma Buber, Matot 6:1
ד"א נקום נקמת בני ישראל. זש"ה לא יגרע מצדיק עיניו (איוב לו ז), מהו לא יגרע מצדיק עיניו, אין הקב"ה מונע מצדיק מה שרוצה לראות בעיניו, מלמד שהיה משה מתאוה לראות נקמת המדינים קודם שימות, ועליו נאמר ישמח צדיק כי חזה נקם (תהלים נח יא), ישמח צדיק זה משה, כי חזה נקם, נקמת מדין, פעמיו ירחץ בדם הרשע (שם), זה בלעם.