In reading the Old Testament for seminary this year I stumbled upon Numbers 31:1-18, in which Israel destroys a city and takes the spoils to Moses. When their prophet Moses finds out, however, that they have saved the married women and man-children, he orders their deaths so as not to upset the Lord. Avoiding the explanation of mistranslation, how can this be just? Every time I hear a testimony or see a child at church my heart burns with anguish to know Jesus commanded such death.
Sometime ago I dealt with the general principles underlying your question, and that answer can be found at this link. I hope you will take a look at it before proceeding on with the rest of this answer.
The necessity of the male children dying becomes, I think, one of those unexplained and frankly horrifying matters that I mentioned in my previous answer. But as regards the women described in Numbers 31, there was some additional background that may add some perspective. The Midianites, in alliance with the Moabites, had attempted to bribe the prophet Balaam into cursing Israel. When that attempt was unsuccessful, Balaam apparently advised his sponsors that Israel’s power could be neutralized by enticing Israel away from Jehovah-worship. Accordingly, the Moabites (and at least a few Midianites) sought to entice Israel into sexual immorality and idolatry. The result of this apostasy, as described in Numbers 25, was a plague that resulted in the deaths of (if the text is accurate) some twenty-four thousand Israelites.
Notably, in verse 17 that Moses isn’t requiring the executions of the married women. He is requiring the executions of the non-virgins. From Moses’ standpoint, the women the Israelite men had brought back to camp could well have included the very same women who had earlier instigated a catastrophic apostasy in Israel. Moses’ orders may well have arisen from the belief that Israel simply couldn’t afford to have any such women re-introduced into their camp.
This, I realize, is hardly a definitive answer; and even if it were, it would continue to be both tragic and deeply disturbing. Four thousand years after the fact, we do not–can not–know all of the factors that led Moses to believe that actions such as this were appropriate and even necessary. As I mentioned in my prior answer, we can only give thanks that in this dispensation we are under divine command to “renounce war and proclaim peace” (D&C 98:16).