Moshe Rabbeinu’s death was dependent upon his waging war against the Midyanites. Why was this so? What would have happened if vengeance had been meted against Midyan after Moshe’s death? Meshech Chochmah posits that had Moshe not been at the forefront of the battle against Midyan, some individuals would infer that Moshe did not support taking adverse action against them. Moshe benefitted greatly from his stay in Midyan. He married the daughter of Yisro, the high priest of Midyan. He lived there for a number of years, safe and secure from the clutches of Pharaoh. Perhaps he was beholden to them. In order to resolve any ambiguities regarding Moshe’s relationship with the Midyanites, it was necessary that he personally oversee their punishment.
Horav Yosef Chaim Sonnenfeld, zl, offers a novel insight to explain the reason for the integral relationship between Moshe’s demise and the war with Midyan. Bilaam, the wicked pagan prophet who was hired to curse the Jews, and succeeded in leading them to sin, died during the war with Midyan. Bilaam was the one who revealed that the power of tumah, spiritual impurity, would “compete” with the power of kedushah, holiness, catalyzed by Moshe Rabbeinu. Hashem purposely created the force of kedushah that Moshe represented in order to reverse the effect engendered by Bilaam. Moshe Rabbeinu’s time for leaving this world was rapidly approaching. He could not depart this world unless something was done to counteract Bilaam’s harmful effect. Moshe was to wage a war against Midyan in order to kill Bilaam and destroy his power of tumah. Afterwards, Moshe’s soul could return to its source.
Pirchei Shoshanah adds that wisdom cannot exist among those who promulgate the power of tumah, who bring spiritual ruin to the world, unless there is a counteractive alternative force of kedushah among the Jews. If we see that, regrettably, the Moshe Rabbeinu’s of a given generation are taken from us, we can be secure in the knowledge that prior to this, the forces of tumah had already been expunged from the world.