Joshua was very old and told the Israelites to stay near to God and stay away from the sins of ungodly. God would punish them if they chose the wrong way.
9 “For the Lord has driven out great and powerful nations for you, and no one has yet been able to defeat you. 10 Each one of you will put to flight a thousand of the enemy, for the Lord your God fights for you, just as he has promised. 11 So be very careful to love the Lord your God.
12 “But if you turn away from him and cling to the customs of the survivors of these nations remaining among you, and if you intermarry with them, 13 then know for certain that the Lord your God will no longer drive them out of your land. Instead, they will be a snare and a trap to you, a whip for your backs and thorny brambles in your eyes, and you will vanish from this good land the Lord your God has given you.
14 “Soon I will die, going the way of everything on earth. Deep in your hearts you know that every promise of the Lord your God has come true. Not a single one has failed! 15 But as surely as the Lord your God has given you the good things he promised, he will also bring disaster on you if you disobey him. He will completely destroy you from this good land he has given you. 16 If you break the covenant of the Lord your God by worshiping and serving other gods, his anger will burn against you, and you will quickly vanish from the good land he has given you.”