That last point is why I led with the moral/allegorical interpretation of the passage. Frankly, I don't fully understand why God would command the Israelites to kill all of the Canaanites, but I do understand that when I read it today, I can understand it as an admonition to aggressively root out all the things in my life that will draw me away from God.
Yet, we can't simply discard the literal meaning of the text, and those passages are definitely among the most difficult to understand literally, at least from a moral framework shaped by the incarnation, death, and resurrection of God.
God also allowed divorce in ancient Israel, but Jesus forbids it to Christians. Is this a contradiction? It sure can feel that way sometimes. Is God "allowed" to command what he pleases? Yes.
Now, this goes back to the ancient question: "Does God commands something because it is just, or is it just because he commands it?" I tend towards the Medieval view of divine simplicity—that God is identical with all of his attributes. So God and justice are the same thing. Which suggests to me that if these passages of Scripture don't *appear* just, it must be because I am failing to grasp some underlying unity.
All this isn't much in the way of answers, but it's how I try to think about such things.
This is something that Alexandria will be able to answer itself one day with the right vector representation, but how did St. Thomas of Aquinas square that particular circle?
A bit of searching brought this up; Article 5 is especially pertinent:
https://www.newadvent.org/summa/2094.htm
Thomas asserts God's absolute sovereignty over life and death, saying:
"All men alike, both guilty and innocent, die the death of nature: which death of nature is inflicted by the power of God on account of original sin, according to 1 Samuel 2:6: "The Lord killeth and maketh alive." Consequently, by the command of God, death can be inflicted on any man, guilty or innocent, without any injustice whatever."
All the objections and replies are worth a read, though.
While searching I also read the suggestion that the commands we see to put all the Canaanites to the sword was a Hebrew idiomatic hyperbole; indeed we see examples of hyperbole throughout Scripture ("If your eye causes you to sin,..." etc.).
If this is the case, then, as you suggested earlier, perhaps we are not to take it absolutely literally, in which case the moral or spiritual meaning becomes primary in governing our understanding of such passages.
It's still hard to conceive a god who kill innocent children en masse. Where's justice in that? To make justice you need first that someone conscientiously commits a crime and the punishment must fit the crime. If your god can break this rule then he's committing a contradiction of the rules which himself created, if he's contradictory then he isn't a real god
If you cook a meal, do you not have both the power and right to share it with whom you please, or to not share it at all?
That's exactly what I'm trying to point out: if the god of the Bible can change the notion of justice (opening exceptions from the natural law which himself supposedly created) whenever he wants then he cannot be a god, because one of the characteristics of the God is being perfect and immutable, if he can "change his mind" about what is justice then he's mutable and mutability is not perfect
Did you read the except from the Summa? It addresses that very question.
Another example how the Bible is contradictory:
"The Lord reigns forever; he has established his throne for judgment.
He rules the world in righteousness and judges the peoples with equity."
(Psalm 9:7-8)
If he "judges with equity" why did he command the killing of innocent children?