The command by God to kill all inside a city is seen by many to be immoral and a demonstration that the Bible is not true. But, we must examine the issue in light of its context - its biblical context - not in light of present-day, non-Christian assumptions. If we want to see if it is moral or not, we must know which morals are in question.
Deuteronomy 2:33-34, "And the Lord our God delivered him over to us; and we defeated him with his sons and all his people. So we captured all his cities at that time, and utterly destroyed the men, women and children of every city. We left no survivor."
First of all, the context of this verse is dealing with the wickedness of the Amorite king Sihon of Hesbon, a city of the Amorites (Num. 21:25). They were a wicked people (Gen. 15:16; 2 Kings 21:11). When the Israelites wanted to pass through their land during their exodus from Egypt, the Amorites refused them safe passage and attacked the Israelites. However, they were soundly defeated by Israel (Num. 21:21-31). It is in this context that God delivered them over to the Israelites, that is, in the context of the battle.
Why would the decision of the Amorites be so serious to God that He would have all their people wiped out? The answer is simple. God tells the Israelites why the people were destroyed. It was because of the wickedness of the Amorite people.
Deuteronomy 9:5, "It is not for your righteousness or for the uprightness of your heart that you are going to possess their land, but it is because of the wickedness of these nations that the Lord your God is driving them out before you, in order to confirm the oath which the Lord swore to your fathers, to Abraham, Isaac and Jacob."
God has declared that the Amorite people deserved to die because of their sins. They remained unrepentant (unlike Nineveh), and the righteous wrath of God fell upon them via the Israelites. Since all are sinners, all deserve to die. They were no exception. Nevertheless, God is merciful by allowing them to live. In the case of the Amorites, God was gracious to them by letting them live and enjoy life with its generic blessings from God (provision of rain, sun, water, etc.,) while He encouraged them to repent of their sins. They refused to turn from their immorality and were finally wiped out.
Also, the death of a child might be a very merciful thing because had the child grown up in the sin of the Amorite culture, it would surely have suffered the eternal wrath of God. If the "age of accountability" notion is correct, then God delivered them into His hands; and it is possible that by this they were spared eternal damnation.
The final and most important reason for their destruction is that God needed to keep the messianic line pure so that Jesus could be born and thereby redeem His people so that believers could go to heaven. Without Jesus' sacrifice, all would be damned. If the Amorites were allowed to live, surely they would have influenced the Jewish nation in a harmful way thereby threatening the arrival of the Messiah. Therefore, God in His righteous judgment executed judgment upon them.