In Moshe's final days he is commanded to attack the Midianites. This was the nation that had tempted the people of Israel to horrible sins of immorality and idolatry, such that Hashem struck them with a plague that took the lives of 24,000 Israelites.
And Hashem spoke to Moshe, saying, "Carry out the vengeance of the Children of Israel against the Midianites; afterward you shall be gathered to your people."
And Moshe spoke to the people, saying, "Detach men for the army from you, and they shall be against Midian to bring Hashem's vengeance against Midian. A thousand from each tribe, for all the tribes of Israel shall you send to the army."
Then, out of the thousands of Israel, 1,000 from each tribe were handed over, 12,000 men deployed for the army. And Moshe sent them forth, 1,000 from each tribe to the army, they and Pinhas the son of Elazar the priest to the army, and the holy vessels and the trumpets for blowing in his hand. And they warred against Midian as Hashem had commanded Moshe and they killed every male (B'midbar 31:1-7).
This war is both "the vengeance of the Children of Israel" and "Hashem's vengeance." Clearly, Midian is to be punished for leading Israel to sin against Hashem, and for arousing Hashem's anger against His beloved people of Israel.
This order to Moshe had been mentioned earlier:
And Hashem spoke to Moshe, saying, "Oppose the Midianites and attack them, for they opposed you with their wiles with which they beguiled you in the matter of Pe'or and in the matter of Cozbi, daughter of a prince of Midian, their sister, who was slain on the day of the plague on account of Pe'or (B'midbar 25:16-17).
However, specific instructions for the war are now given:
And they warred against Midian as Hashem had commanded Moshe (31:7).
What were these directives of war? Rambam, in the Laws of Kings and Their Wars (6:7), says that Moshe was taught a law for all wars:
When they besiege a city to capture it they must not surround it from all four sides, but from three sides, and they must leave a place for a deserter or anyone who wishes to save his life, as it says: "And they warred against Midian as Hashem had commanded Moshe." Through the oral tradition the [Sages] learned that it was in this [matter] that He commanded him.
click here to continue reading