God had a no-marry list for Israel. Three of the groups were the children of Moab, Ammon and Canaan. These were all children of Incest. There were others that God told Israel not to marry, but these were the most written about children of incest.
Judah had sinned by marrying a Canaanite woman. God killed his first two sons by the Canaanite woman. God intervened however in that Tamar took her right to children and had Pharez and Zarah by Judah thus preserving the holy seed from Judah.
Another instance is in Ezra chapter nine. The people who had returned to Judea from Babylon were intermarrying with the children of the land.
Ezra 9:12 “Now therefore give not your daughters unto their sons, neither take their daughters unto your sons, nor seek their peace or their wealth for ever: that ye may be strong, and eat the good of the land, and leave it for an inheritance to your children for ever.”
Many say that this rejection of the local people was due to their foreign gods. Interestingly there never was any attempt anywhere in the scripture to convert those people. If it had been about religion they could have just divorced the other people. The rejection by God was based on who they were, not what they believed. An interesting part of the above verse is that Israel should never seek their peace or wealth for ever. Why? Once again it was for the same reason that God had Israel kill off entire populations of people in their past.
“that ye may be strong, and eat the good of the land, and leave it for an inheritance to your children for ever.”
It was for the protection of Israel as a people. It is the same reason we are not supposed to bring in foreigners into our land and communities today.
2 Corinthians 6:17a “Wherefore come out from among them, and be ye separate (to set off by boundary), saith the Lord”.
Philippians 2:15 “That ye may be blameless and unmixed, the sons of God, without rebuke, in the midst of a crooked and perverse race, among whom ye shine as lights in the world”.