Joshua 23:13
Know for a certainty that the LORD your God will no more drive out any of these nations from before you; but they shall be snares and traps unto you, and scourges in your sides, and thorns in your eyes, until ye perish from off this good land which the LORD your God hath given you.
This warning was given in Joshua's address to Israel's leaders after the wars of conquest had ended and the Lord had given Israel rest from its enemies. It was conditional: if Israel turned from God and joined itself to the remaining Canaanite and heathen nations, God would no longer drive those nations out and would withdraw His protecting care. That joining included intermarriage with those nations. In context it warns against idolatry and close ties with idolaters, because such associations would expose Israel to corruption and sin.
If those nations were not promptly destroyed, they would become snares and traps and thorns to Israel. They would become sources of torment and instruments of punishment. Israel's continued protection depended on faithfulness to God, and if they withdrew from Him He would use those nations to chastise them. If unfaithfulness persisted, desolation would follow and Israel would perish from and be driven from the good land God had given them, losing their possessions. The verse thus shows God to be faithful both to fulfill His promises and to carry out His warnings.
The warning was fulfilled in Israel's later history, for after turning to idolatry they were beset and oppressed by surrounding hostile nations and suffered the consequences of apostasy. It also applies personally: individuals must avoid even the appearance of evil, shun dangerous connections, and stay away from the borders of sin. Approaching sin can lead to bondage and ruin.