Deuteronomy 9:4
4-6. Speak not thou in thine heart, . . . saying, For my righteousness the Lord hath brought me in to possess this land—Moses takes special care to guard his countrymen against the vanity of supposing that their own merits had procured them the distinguished privilege. The Canaanites were a hopelessly corrupt race, and deserved extermination; but history relates many remarkable instances in which God punished corrupt and guilty nations by the instrumentality of other people as bad as themselves. It was not for the sake of the Israelites, but for His own sake, for the promise made to their pious ancestors, and in furtherance of high and comprehensive purposes of good to the world, that God was about to give them a grant of Canaan.
Joshua 7:12
10-15. the Lord said unto Joshua, Get thee up—The answer of the divine oracle was to this effect: the crisis is owing not to unfaithfulness in Me, but sin in the people. The conditions of the covenant have been violated by the reservation of spoil from the doomed city; wickedness, emphatically called folly, has been committed in Israel (Ps 14:1), and dissimulation, with other aggravations of the crime, continues to be practised. The people are liable to destruction equally with the accursed nations of Canaan (De 7:26). Means must, without delay, be taken to discover and punish the perpetrator of this trespass that Israel may be released from the ban, and things be restored to their former state of prosperity.