Joshua 23:4

Behold, I have divided unto you by lot these nations that remain, to be an inheritance for your tribes, from Jordan, with all the nations that I have cut off, even unto the great sea westward.

Joshua, near the end of his leadership, divided by lot the territories of the nations that still remained, assigning them as an inheritance to the tribes of Israel from the Jordan westward to the great sea, together with the lands of the nations God had already cut off. This distribution was part of his review of the history of God's dealings with Israel, rehearsing what had been given and what had been accomplished. That review was intended to awaken gratitude for God's providential care and humility as Israel recognized its failures to fully follow His revealed will.

From that setting flowed solemn warnings against the remaining idolatrous nations and against forming close ties with them. Israel was to keep separate from them in order to avoid their corrupting influence. Turning away from God to follow their ways would bring desolation upon Israel, for the same faithfulness by which God fulfilled His promises would also fulfill His threatened judgments. What was true of the nation in this warning is true for each individual person.