Deuteronomy 20:16

But of the cities of these people, which the LORD thy God doth give thee for an inheritance, thou shalt save alive nothing that breatheth:

Of the cities given to Israel for an inheritance, the command was to save alive nothing that breathes, requiring the destruction of every living thing in the Canaanite cities, including Jericho. It was given because Canaanite idolatry and depravity would have prevented Israel from fulfilling its purpose to establish a nation that would display God's kingdom and spread true religion. The inhabitants had ample opportunity to repent, for they had heard of the Red Sea and the judgments upon Egypt and of Israel's victories over Midian, Gilead, and Bashan. Through those events they knew Jehovah's power and holiness, yet many refused to obey. Their destruction was therefore an act of both love and justice, removing people who rebelled against God and harmed humanity.