One of the most difficult things to understand about the Old Testament is the supposed "genocide" committed by God. Of course, contrary to unbelieving claims, there is no genocide in the Bible. Indeed, in the eyes of God, the only logical way to commit genocide would be to completely destroy the human race, which, although He has the absolute right to do, He has no intention of doing.
Nevertheless, there are certainly examples in the Old Testament of when God did, in fact, destroy entire cities, punish entire nations, and at one point, even flood out the entire planet. How are we, as Christians, able to justify this kind of behaviour?
The first thing to note is that we actually don't have to. In fact, it is an abomination to believe that any human being can stand in judgement over God. What would give us that right? What is so significant about a human being that we should believe we get to decide when God is right, and when God is wrong? A child has more authority over a king than a man has over God.
Nevertheless, being made in the image of God brings with it a godly sense of justice. It is warped, as of course we are sinners. We have a twisted sense of justice, one that is usually biased towards our own self interest. Nevertheless, we do have a sense of justice. It is legitimate for us to try to understand why God does as He does, and as Christians, it may remove a stumbling block to faith if we can "justify" God in the eyes of the unsaved. Thus, we can point out the extent of the sin being judged.
First, let us refer to a conversation God had with Abraham, in Genesis 18, concerning the upcoming judgement of Sodom and Gomorrah. Moved with compassion, Abraham interceded for Sodom, asking God "Would You also destroy the righteous with the wicked? Suppose there were fifty righteous within the city; would You also destroy the place and not spare it for the fifty righteous that were in it?" God, of course, said no. For the sake of just 50 righteous people, God would not destroy the city. Abraham speaks up again, asking if God would spare it for 40, 30, 20, just 10 righteous people. Out of fear, Abraham doesn't go any lower, but God does say "I will not destroy it for the sake of ten."
So we see that as many as 50, or as few as 10 people are sufficient to save an entire city from the wrath of God. What's more is that God actually gives both warnings (see the account of Jonah), and even a grace period, sometimes spanning several generations. We see this in Genesis 15:12-16, which says "Now when the sun was going down, a deep sleep fell upon Abram; and behold, horror and great darkness fell upon him. Then He said to Abram: “Know certainly that your descendants will be strangers in a land that is not theirs, and will serve them, and they will afflict them four hundred years. And also the nation whom they serve I will judge; afterward they shall come out with great possessions. Now as for you, you shall go to your fathers in peace; you shall be buried at a good old age. But in the fourth generation they shall return here, for the iniquity of the Amorites is not yet complete.”"
From this, we see that though God would eventually destroy the Amorites, He actually waited for them to get as bad as they could. 400 years of impenitent sinners, each generation becoming more wicked than the last. God waited for the sin of the Amorites to get to its highest point, and when there were not even 10 righteous people among them, God finally judged them.
This tells us a lot. First, consider that in order for a sin to be national, it must also be individual. It must be committed, or at least tolerated, by the vast majority of people. Socialism is an excellent example. Socialist leaders both gain and maintain power by capitalising on the greed of the people. Most ideologies cannot gain power when they are a cultural minority, but when they are at least somewhat popular, they can gain love, or even just sympathy, and that gains them power. So we see that sin needs to be individual before it even comes close to being national.
Furthermore, this shows us that sin is contagious. While it is indeed possible to break a chain if just one man repents, sins usually get passed from one generation to the next. Like father, like son. This allows the same sins to be repeated for generations. To add an extra layer to this, God actually knows it. He knows who will repent and who won't. Because of this, even if an infant is killed, this may actually be a greater mercy than allowing them to survive. A dead infant is innocent before God, and granted eternal life, whereas a sinful man, whether he lives to old age, or perishes by the sword, receives eternal condemnation.
Now, to some unbelievers, that might sound repugnant. Others might even say "if that's the case, why not just kill all babies?" The sickest minded among the unbelievers may even shout the atheist cliche "abortion sends babies to God faster!" But these two attitudes are because, as unbelievers, they are not eternally minded. We do not see what God sees, and most of us do not even see what we ought to see (although from the other side, we will fully understand what we ought, and no one will feel they have been unfairly treated by God). The Bible unequivocally states that death is a bad thing. It is an enemy in our world, and is the last enemy that will be destroyed. It is, indeed, merciful for God, in His infinite wisdom, and authority, to save an infant before they are ever defiled by sin. We, however, lack that wisdom (we do not know who or what that child will become), and lack the authority. Murder is evil. Divine judgement is not.
Ultimately, all earthly judgements are just a shadow of what is to come. God's judgements on this side are temporary, but on the other side, they are permanent. God cannot abide with sin. That which opposes Him is destroyed as wood in a fire. Nobody calls fire evil when it burns wood. So also can nobody call God evil for destroying sinners. It is in His nature, and it is in His rights. This is scary, as we ourselves are deserving of this very wrath. However, destruction is never God's preference. The Bible tells us repeatedly that God takes no pleasure in the death of the wicked.
As God does not want to punish us, He gave us an alternative. Jesus entered creation as a man, lived a perfect life, and died for sin. Then He rose again. All those who repent of sin, confess Him as Lord, and believe He rose from the dead, will not only be spared the ultimate judgement, but also inherit eternal life in Heaven, as if we had lived the life Jesus lived. This is not a God who enjoys torture, but who takes great pleasure in giving life. Let Him give it to you.