Joshua 24:18

And the LORD drave out from before us all the people, even the Amorites which dwelt in the land: therefore will we also serve the LORD; for he is our God.

Near the end of his life Joshua reviewed God's providential care alongside Israel's failures to bring the people to gratitude and humility. The Lord drove the Amorites and the other peoples out from before Israel, and Israel's resolve to serve the Lord as their God rests on that deliverance. The commitment renews the covenant to serve and obey God because He brought Israel out of Egypt, performed signs for them, and preserved them on their journey.

The declaration belongs to a farewell warning against idolatry and against close ties, including marriage, with idolaters, because such ties corrupt and lead to sin and ruin, and God will fulfill both His promises and His warnings. The chapter records a revival among God's ancient people, and all who name the name of Christ should read it carefully and with an understanding heart to search their own hearts whether they are in the faith. The warning applies personally as a call to avoid even the borders of sin.