There are many verse in the Old Testament that God Kill People that against him. He want to show that He is God and no other gods before him or after him.
God did not kill babies in the old testament,
God test Abraham's Faith and Love to Him...God commands Abraham to offer Isaac... Genesis 22:1-19
God Kill all People in Sodoma & Gomora, because they are all sinners, They did not obey God. they worship Idols and Images, did not make sex to a woman, but they make it in their same sex. Genesis 19:1-33
God Show His Power to the Egyptians for the freedom of the Hebrews in the house of bondage. God makes many miracles and evidence that He is God, the most powerful and there is no other than Him, Egyptian kill babies because the Hebrews become more in population than Egyptians and they become slaves, Egyptians Worship images and did not Believe in God of Israel..
Exodus and Deuteronomy.
God dismayed because he created Human and become evil in their lives and they do what they want. But God was pleased with Noah. and He kill every living creature in Earth but God save Noah and His family, and a Pair of every kind of animals.
Genesis 6:1-22
God has a Right to do what he want and we are all servants and we don't have the rights to ask him why he did it or that....
God make all Things good, right and Beautiful.
God has a Plan to those who love Him and Worship him in his way.
Exodus