This is one of those passages where what it doesn't say is as important as what it does.
"When the LORD your God brings you into the land you are entering to possess and drives out before you many nations ... Make no treaty with them, and show them no mercy. Do not intermarry with them. Do not give your daughters to their sons or take their daughters for your sons ..." (Deut 7:1-3).
First, what it doesn't say.
There is an unfortunate history of people trying to bend, fold, and mutilate the Bible to support racism and, in this case, laws against "miscegenation" (i.e., mixed "race" marriages). Of course, to do that you must first invent the notion of race — the idea that there is some kind of important genetic difference between different people groups. The Jews were descended from Noah's son Shem. The Canaanites, etc. were descended from Noah's son Ham. So these groups are basically cousins — as are all humans since we are all descended not only from Adam but also from Noah through one of his three sons. People in different areas developed different physical characteristics, be we all have the same blood coursing through our veins.
These were not the only distant relatives they were not allowed to intermarry with. They could not intermarry with the Moabites, descendants of Lot, Abraham's nephew (Dt 23:3).
It wasn't "other people groups" that they weren't allowed to marry. They could marry other peoples, just not these. To the point, Moses married a Cushite woman — that is, a woman from far southern ancient Egypt (an area now called "Sudan"), more descendants of Ham (Num 12:1) and quite likely black-skinned. God was apparently cool with that. Honestly, the Jews at this point probably weren't even a homogeneous people; the group that left Egypt included more than just the literal children of Israel (Ex 12:38). The prohibition wasn't against marrying other peoples but specific peoples.
So if this isn't about race, what is it about? Religion.
"Do not intermarry with them. Do not give your daughters to their sons or take their daughters for your sons, for they will turn your children away from following me to serve other gods, and the Lord’s anger will burn against you and will quickly destroy you."
Don't intermarry with these pagans, God says, or they will corrupt you and then I will have to destroy you. Which is of course what happened. Israel did intermarry with them, and they did worship their idols. Even Solomon in his wisdom was not immune to the charms and deleterious effects of pagan women. This continued to be a problem even after the exile for idolatry into Ezra and Nehemiah's day (Neh 13:23-28).
God wants his people to separate from the evil people around them. To borrow from Jesus, a little yeast works its way through the whole loaf. When righteous people and unrighteous people get too cozy, the righteous are usually the ones who are changed. This includes marriage (2Cor 6:14), but I think it is wise to take it farther than just marital relationships.
That's not to say we should have no contact with the lost people around us, but we do need to beware how close we let people get. Getting too close to non-Christians can make us doubt the faith. Getting too close to unrepentant sinners can lead us into their sin. Love these people, but build your closest relationships with people who will be good for your soul.
The church is literally those who have been "called out." So we must come out from among the lost and stand out, be different from them. Then they can see the difference and ask where it comes from. And then we can give them the reason for the hope that is within us.