WHY WAS GOD SO VIOLENT IN THE OLD TESTAMENT?
After mankind fell to sin, God promised a Savior who would defeat sin (Genesis 3). The Old Testament is the account of God preparing to send that Savior. He would start by establishing the nation of Israel. Through that nation would come Jesus, the Savior, who would save mankind from their sins.
On the other side we find Satan who is attempting to keep the Savior from coming. He first tries to stop the formation of Israel then, when that fails, attempts to destroy them. He does this by influencing Israel's enemies to attack and by trying to lead them astray through various sins.
Now. if there's no Israel there's no Savior, if there's no Savior there's no hope for mankind. With this thought in mind we can begin to better understand why God had dealt so harshly with those who threatened Israel’s existence. God was protecting nothing less then His plan of redemption. If He had failed to take action we would have all been lost. It was a unique period in history.
That said God’s grace and mercy is shown throughout the Old Testament. Noah, Abraham, David, the people of Israel and so many others sinned again and again and each time God was there was forgive and restore them.