Possible depiction of Jehu King of Israel giving tribute to King Shalmaneser III of Assyria, on the Black Obelisk of Shalmaneser III from Nimrud (c. 827 B. C.) [Wikimedia Commons / Creative Commons Attribution-Share Alike 3.0 Unported license]
One of the most poorly understood aspects of the Old Testament (hence brought up a lot to us apologists) are the wars where God tells the Israelites to slay every man, woman, and child. This is seen as the equivalent of the evil massacres such as we see today. They are not at all.
What is missed is that these are instances of God’s judgment upon the particular nations involved, since they have reached an apex of wickedness and point of no return. God then uses the Jews as His agent of judgment. When they messed up and rebelled, they were judged as well: by the Egyptians, by the Assyrians and Babylonians, and later the Romans. But their judgment wasn’t to annihilation, because they were still His chosen people, to bring His message of grace and salvation to all of mankind.
Now, here is a quick proof of this: the key verse of which just happened to catch my eye today, while looking for something else. The Hebrews / Israelites / Jews were to inherit the Promised Land. In order to do that, they had to drive out several nation-states that inhabited it already. Here is what God said to Abraham, when He told him he was to be a great father of nations:
Genesis 15: 13-16 (RSV) Then the LORD said to Abram, “Know of a surety that your descendants will be sojourners in a land that is not theirs, and will be slaves there, and they will be oppressed for four hundred years;  but I will bring judgment on the nation which they serve, and afterward they shall come out with great possessions.  As for yourself, you shall go to your fathers in peace; you shall be buried in a good old age.  And they shall come back here in the fourth generation; for the iniquity of the Amorites is not yet complete.”
See that last word, “complete”? That goes with “iniquity.” The idea was that the wickedness of the Amorites would not yet reach its fullness — be “complete” — till another four generations (roughly 120-160 years). At that time, in God’s Providence they were to be judged, and that was by the Jews as God’s agent of judgment, when they took over their land. God thus accomplishes two things: judges one nation and gives to another the land He promised to them. Both things are just and righteous. God has the right to utterly judge and kill even a whole nation because He is the creator, and gave moral standards to men, that they fully know from conscience, even prior to receiving revelation.
God makes it quite clear in many passages, that HE is the one acting: driving our and/or destroying nations. The Jews were just His vessels (Ex 23:23; 33:2; 34:11; Dt 7:1; 31:4; Josh 3:10; 10:12; 24:8, 18; 1 Ki 21:26; many more). Because He is the one judging wicked nations; therefore He gives orders like the following:
Deuteronomy 20:16-17 But in the cities of these peoples that the LORD your God gives you for an inheritance, you shall save alive nothing that breathes,  but you shall utterly destroy them, the Hittites and the Amorites, the Canaanites and the Per’izzites, the Hivites and the Jeb’usites, as the LORD your God has commanded;
God also makes it clear that this is not because the Jews were inherently superior to the nations being judged:
Deuteronomy 9:3-6 Know therefore this day that he who goes over before you as a devouring fire is the LORD your God; he will destroy them and subdue them before you; so you shall drive them out, and make them perish quickly, as the LORD has promised you.  “Do not say in your heart, after the LORD your God has thrust them out before you, `It is because of my righteousness that the LORD has brought me in to possess this land’; whereas it is because of the wickedness of these nations that the LORD is driving them out before you.  Not because of your righteousness or the uprightness of your heart are you going in to possess their land; but because of the wickedness of these nations the LORD your God is driving them out from before you, and that he may confirm the word which the LORD swore to your fathers, to Abraham, to Isaac, and to Jacob.  “Know therefore, that the LORD your God is not giving you this good land to possess because of your righteousness; for you are a stubborn people.”
These nations are judged “because of . . . wickedness” (Dt. 9:4-5), and the exact time is foreknown by God: precisely when their “iniquity . . . is . . . complete” (Gen 15:16).
How much is in a word! “Complete” in context here says it all . . . But one must understand beforehand basic “theology of God” concepts such as Providence, foreknowledge, and God’s prerogative of judging nations for sin, via secondary agents. On a few occasions, God basically acts alone in judgment: such as Sodom and Gomorrah, which were destroyed (Gen 19:24-25) because not even ten righteous people could be found in them (Gen 18:20-21, 32). But even here, the Bible informs us that two angels assist in destroying them (Gen 19:1, 13).
For further reading on this vexed topic:
Did God Harden Pharaoh’s Heart? (Does God Positively Ordain Evil?) (vs. [atheist] “DagoodS”)
NOTE: This topic is too emotional for most people to discuss with objectivity (it’s right up there with hell); therefore, I have closed the comments. The excessively emotional comments / queries that were formerly here have been replied to already in one or more of the above papers.I urge anyone who has questions about these matters to read some of the papers above.