A few chapters ago God used a plague to bring judgement on the Israelites. But now God uses Israel to destroy the Midianites, maybe so that all the other nations along the path to canaan will know they are chosen and steer clear.
This sad story is a sequel to the scenes in 23-25 of the Moab King and Baalam the diviner/prophet who kept telling the King that God was with the Israelites and he should not try to fight them or it would be their doom.
The king seemed to have deliberately tried – with some success – to break down the Israelite’s religion with their own particular belief system that seemed to involve casual sex with attractive women.
Its hard to contemplate all those ancient lives. Human souls as precious as anyone. What sort of lives did they have those temple prostitutes?
Were there any among those destroyed who God loved? Balaam was killed. He was a prophet for hire, but he spoke glorious words about God. Surely there were others who knew at least moments of blessing we didn’t even hear about. That is between god and each person. But their time on earth was over, and the Israelites dealt the blow.
The habits of war was to take all the women children and treasure as spoils for the victors, which the Israelites did, not focussing on the fact that they were being instruments of god’s judgement, not a conquering army.
They weren’t victors, they were supposed to be more like a destructive force of nature: a plague, flood, earthquake or old age. Literally an act of God. They weren’t to profit from it.
So the rest of the chapter is an awkward and unsatisfactory compromise to return the spoils to God, including the humans, some of whom are even allowed to live a bit longer, in a way that is as fair as can be in the circumstances. Plan B, second best, God getting into the messiness of disobedience.