In the Bible, there are many instances where God commands the Israelites to attack other people, and sometimes, wipe out their entire population.
For example:
These events are often used to attack the Bible, as God is charged with being cruel or unjust for commanding these things to happen. How should we understand these passages?
In exactly zero of the above cases did God command the Israelites to attack innocent, peace-loving people groups.
In the Bible, God makes it very clear that the people in Canaan, in particular, had done horrendous, abominable things, and that was why they were being driven out:
Deuteronomy 9:5
5 Not for thy righteousness, or for the uprightness of thine heart, dost thou go to possess their land: but for the wickedness of these nations the Lord thy God doth drive them out from before thee, and that he may perform the word which the Lord sware unto thy fathers, Abraham, Isaac, and Jacob.
Repeatedly, we are told about the wicked things that the Canaanites did, including idolatry, adultery, homosexuality, child sacrifice, and bestiality (Leviticus 18:1-30, Deuteronomy 9:4-5, 12:29-31, 18:9-14: 2 Kings 16:3, 21:2-9). And, we are told that if the Israelites wouldn't have driven them out, God still would have punished them (Numbers 33:56).
So, not only were the people that God had the Israelites wipe out not innocent, they were exceptionally evil and corrupted, to the point were in some cases, their children, and even their animals had to be killed.
The issue that unbelievers have with these passages seemingly has a lot to do with the fact that God was using human beings to conduct the actual killing. They spend a lot of time focusing on the fact that the Israelites were the actual agents going in, and carrying out the violent retribution themselves.
Why though? How is using human beings to carry out the punishment any different from, for instance:
If people deserve judgment, God can carry it out "naturally" - using other people, disease, or natural disasters (Amos 3:6, etc.) - or, He can do it supernaturally, and He has reasons for choosing whatever He ultimately decides to do.
In many of the examples above, children were killed as part of the judgment. No one is denying that, and no one is denying that it was a tragedy.
However, children that have not yet reached the age of moral reasoning, along with the mentally disabled, are not condemned before God as sinners. They went to Heaven when they died, and though they died, they were ultimately rescued from the wicked, perverted people amongst them, who were going to raise them to be just as wicked and perverted as they were.
Recall that God knows everything, including exactly how much more wickedness would have resulted in each situation, if the group in question wasn't destroyed. Sometimes, a partial destruction was deemed enough. Other times, it had become so corrupt, that God was signaling that if they weren't completely destroyed, it would simply create more wickedness and suffering in the future.
Humbly acknowledge that God is perfectly just, and surely knows infinitely more about each situation above than any sinner in the 21st century standing in judgment of Him. He knows that children died, and He knows that they weren't to blame, and has dealt completely fairly with them. Those children are in Heaven right now, agreeing with God's judgment on their wicked ancestors.
Objections to these accounts, or really anything God does, are illogical, because God is the standard of morality. God has all knowledge, and so no one can ever submit a "better" morality to overthrow His, or challenge any of His conclusions.
What God does and commands is always righteous, and if you were alive when these accounts were taking place, and could see the kinds of people God was judging, and what they did - or if you could look into an alternate history where these people weren't destroyed, and see all the horror and death that would have resulted, you would think twice about questioning whether God was out of bounds in commanding they be taken out.