It's the context.
Now therefore kill every male among the little ones, and kill every woman that hath known man by lying with him. But all the women children, that have not known a man by lying with him, keep alive for yourselves.
(Num 31:17-18 KJV)
Anyway, it is lights out time here.
For the idea of clearing infection to apply to the act against Midian one would think there would have to be mention of something that could cause infection.
The Book of Numbers 31
Vengeance on Midian
The Lord spoke to Moses, saying, 2 “Avenge the people of Israel on the Midianites. Afterward you shall be gathered to your people.” 3 So Moses spoke to the people, saying, “Arm men from among you for the war, that they may go against Midian to
execute the Lord's vengeance on Midian. 4 You shall send a thousand from each of the tribes of Israel to the war.” 5 So there were provided, out of the thousands of Israel, a thousand from each tribe, twelve thousand armed for war. 6 And Moses sent them to the war, a thousand from each tribe, together with Phinehas the son of Eleazar the priest, with the vessels of the sanctuary and the trumpets for the alarm in his hand. 7 They warred against Midian, as the Lord commanded Moses, and killed every male. 8 They killed the kings of Midian with the rest of their slain, Evi, Rekem, Zur, Hur, and Reba, the five kings of Midian. And they also killed Balaam the son of Beor with the sword. 9 And the people of Israel took captive the women of Midian and their little ones, and they took as plunder all their cattle, their flocks, and all their goods. 10 All their cities in the places where they lived, and all their encampments, they burned with fire, 11 and took all the spoil and all the plunder, both of man and of beast. 12 Then they brought the captives and the plunder and the spoil to Moses, and to Eleazar the priest, and to the congregation of the people of Israel, at the camp on the plains of Moab by the Jordan at Jericho.
13 Moses and Eleazar the priest and all the chiefs of the congregation went to meet them outside the camp. 14 And Moses was angry with the officers of the army, the commanders of thousands and the commanders of hundreds, who had come from service in the war. 15 Moses said to them, “Have you let all the women live? 16
Behold, these, on Balaam's advice, caused the people of Israel to act treacherously against the Lord in the incident of Peor, and so the plague came among the congregation of the Lord. 17 Now therefore, kill every male among the little ones, and kill every woman who has known man by lying with him. 18 But all the young girls who have not known man by lying with him keep alive for yourselves. 19 Encamp outside the camp seven days. Whoever of you has killed any person and whoever has touched any slain, purify yourselves and your captives on the third day and on the seventh day. 20 You shall purify every garment, every article of skin, all work of goats' hair, and every article of wood.”
21 Then Eleazar the priest said to the men in the army who had gone to battle: “This is the statute of the law that the Lord has commanded Moses: 22 only the gold, the silver, the bronze, the iron, the tin, and the lead, 23 everything that can stand the fire, you shall pass through the fire, and it shall be clean. Nevertheless, it shall also be purified with the water for impurity. And whatever cannot stand the fire, you shall pass through the water. 24 You must wash your clothes on the seventh day, and you shall be clean. And afterward you may come into the camp.”
25 The Lord said to Moses, 26 “Take the count of the plunder that was taken, both of man and of beast, you and Eleazar the priest and the heads of the fathers' houses of the congregation, 27 and divide the plunder into two parts between the warriors who went out to battle and all the congregation. 28 And levy for the Lord a tribute from the men of war who went out to battle, one out of five hundred, of the people and of the oxen and of the donkeys and of the flocks. 29 Take it from their half and give it to Eleazar the priest as a contribution to the Lord. 30 And from the people of Israel's half you shall take one drawn out of every fifty, of the people, of the oxen, of the donkeys, and of the flocks, of all the cattle, and give them to the Levites who keep guard over the tabernacle of the Lord.” 31 And Moses and Eleazar the priest did as the Lord commanded Moses.
32 Now the plunder remaining of the spoil that the army took was 675,000 sheep, 33 72,000 cattle, 34 61,000 donkeys, 35 and 32,000 persons in all, women who had not known man by lying with him. 36 And the half, the portion of those who had gone out in the army, numbered 337,500 sheep, 37 and the Lord's tribute of sheep was 675. 38 The cattle were 36,000, of which the Lord's tribute was 72. 39 The donkeys were 30,500, of which the Lord's tribute was 61. 40 The persons were 16,000, of which the Lord's tribute was 32 persons. 41 And Moses gave the tribute, which was the contribution for the Lord, to Eleazar the priest, as the Lord commanded Moses.
42 From the people of Israel's half, which Moses separated from that of the men who had served in the army— 43 now the congregation's half was 337,500 sheep, 44 36,000 cattle, 45 and 30,500 donkeys, 46 and 16,000 persons— 47 from the people of Israel's half Moses took one of every 50, both of persons and of beasts, and gave them to the Levites who kept guard over the tabernacle of the Lord, as the Lord commanded Moses.
48 Then the officers who were over the thousands of the army, the commanders of thousands and the commanders of hundreds, came near to Moses 49 and said to Moses, “Your servants have counted the men of war who are under our command, and there is not a man missing from us. 50 And we have brought the Lord's offering, what each man found, articles of gold, armlets and bracelets, signet rings, earrings, and beads, to make atonement for ourselves before the Lord.” 51 And Moses and Eleazar the priest received from them the gold, all crafted articles. 52 And all the gold of the contribution that they presented to the Lord, from the commanders of thousands and the commanders of hundreds, was 16,750 shekels.[
a] 53 (The men in the army had each taken plunder for himself.) 54 And Moses and Eleazar the priest received the gold from the commanders of thousands and of hundreds, and brought it into the tent of meeting, as a memorial for the people of Israel before the Lord.
Footnotes
- Numbers 31:52 A shekel was about 2/5 ounce or 11 grams
The incident at Peor
The Book of Numbers chapter 25
While Israel lived in Shittim, the people began to whore with the daughters of Moab. These invited the people to the sacrifices of their gods, and the people ate and bowed down to their gods. So Israel yoked himself to Baal of Peor. And the anger of the Lord was kindled against Israel. And the Lord said to Moses, “Take all the chiefs of the people and hang them in the sun before the Lord, that the fierce anger of the Lord may turn away from Israel.” And Moses said to the judges of Israel, “Each of you kill those of his men who have yoked themselves to Baal of Peor.”