This is partially explained by the previous question and post: [cref how-can-an-all-good-all-powerful-god-allow-disasters-like-hurrican-katrina-famines-and-war] However, I decided this deserved a little further explanation because God directly ordered the Israelites to kill non-soldiers. My answer assumes you have read this previous post, and the [cref logically-christian-basic-philosophy Basic Christian Beliefs or Philosophy] so if you have not, please do so before proceeding.
First, lets remember God’s perspective: all humans, who are immortal, over all time and who have forever in heaven or hell as a destiny, and death is not an end, but a change. These exterminations served both an immediate purpose for the Israelites, and a much larger purpose for us all.
Second, we need to put this within the context of the entire Bible. The Bible has an Old Testament (Covenant or Agreement) and and New Testament. The Old Covenant was simply this: God will make the rules, if you follow the completely and perfectly you will be good enough to go to be with God forever. Of course, no one could accomplish that, which is the real purpose of the Old Testament: to prove to the Israelites, and all humanity for all time, that we are weak and sinful and we will fail and we cannot be good enough. Many times in the Old Testament God goes to great extremes and allows great sacrifices to make this lesson absolutely clear.
God was brining the Israelites into a land inhabited by people who worshiped idols. Their worship and conduct and ideals and philosophies were directly opposed to God. He was asking his people to remain faithful to him and follow his rules and worship him completely and perfectly. If they were to stand a chance, the opposing influences need to be completely removed from their lives. To ask the Israelites to follow him completely, and then throw them into a melting pot of opposing influences could have been seen as unjust. Would you ask an alcoholic to live in a bar? Have you ever tried dieting when you work in a fine restaurant? So you see, this was a choice God made for the sake of his own people that was reasonable. Especially if viewed from the perspective of teaching all immortal beings, for all time, in all generations, that they cannot fulfill the Old Covenant agreement.
On a more personal level, this story has proven to teach several great lessons for all of God’s followers through the thousands of years that followed. If I want to live a pure life, this lesson instructs me to be radical about removing temptations from my life. And while I should be radical about removing temptation, I will still fail, just as the Israelites did. It also teaches me to choose my friends carefully. I have seen Christians and atheist who have chosen to date. Eventually, one or the other converts. And quite frankly, the man almost always converts to whatever the woman is. We men are easily led by a beautiful woman. For God to have spared the women and children would have doomed Israel to failure and for Christians to have intimate relationships with non-Christians is just as foolish.
So in summary, I believe if we look at things from God’s perspective of doing what is best for all people, who are all immortal, for all time, actions such as these become very reasonable. We humans make the same choice all the time when the stakes are high enough. If your arm has gangrene, you will amputate it. It is painful, but it is better than allowing it to kill your entire body. The body that is humanity needs amputation sometimes, admit it. We as a group are sick, injured, and at war. We need chemo-therapy and surgery sometimes. When we act toward our own bodies the way God acts toward all of humanity we see it as reasonable, so we cannot condemn God for acting with equal reason when in reality the “stakes” are much higher in his decisions.[cref logically-christian Logically Christian Home Page]