Why did God Kill Everyone Including Children in Jericho?

When Joshua led the Israelites into the promised land, Jericho was the first city they came to and God called on them to completely destroy it. This circumstance is very hard to grasp when we think about all of the innocent people, including children, that were killed. Sometimes we justify it that Jericho was evil and God was punishing them. That may be partially true, but I believe it misses two critical points. 

First, the physical Israelites represent us as spiritual Christians. 

When we start living the life God has called us to live(in the promised land), we find that there are still old habits, bad friends, and other influences around us from our life before our relationship with Christ. God wants us to be ruthless with these. The “good parts” of the bad influence will become a snare to us just as the other nations were to the Israelites(Exodus 34:12). God used the physical Israelites and people of Jericho and other nations to show us that spiritual picture. 

Second, God separates our physical life from our spiritual life. 

In Joshua 2:8-11, Rahab tells the spies, that Joshua sent, that the people of Jericho had seen the Israelites 40 years prior when God freed them from Egypt and parted the Red Sea. They were overwhelmed by the power of the Israelite God. I am guessing the biggest surprise to the people of Jericho was what the Israelites were doing in the wilderness for so long with a God that strong. While God did destroy Jericho, God revealed Himself and His power to the people of Jericho long before they died. In doing so, God protected their souls. He gave them the same spiritual opportunity that we have today. He showed Himself to them as an all powerful God allowing the people to chose to submit to or reject Him. I believe that in Heaven we will see the people from Jericho and the other Canaanite nations that trusted in God before they were killed.