This could be seen as a difficult passage. The thought of all those wives being abandoned as a point of loyalty seems to go against all that God desires. We know He hates divorce. God stands up for the weak and victimized--especially women and children--and this passage stands in stark contrast to what we would normally expect, but there's more to this story than meets the eye.
Had the women wanted to become a part of Israel, there were ceremonies to do so. One noted example is Ruth, who was allowed and encouraged to marry Boaz even though she was from Moab (one of the nations mentioned in this passage). In entreating Naomi to allow her to stay with her three times and vowing to take on Naomi's people and God, she was considered a Jewish proselyte. It was rare but it could be done. Any one of those women could have chosen to become an Israelite and there would have been no problem.
Where the problem comes in is that these women willingly married Jewish men intentionally to drive a wedge between them and their nation and God. The fact that the children couldn't even speak Hebrew, the language of the scripture, was further indication that these were not women who wanted to be a part of their husband's culture, but women who intended to keep their own gods, including detestable practices like child sacrifice and ritualistic prostitution.
One of the wildest comparisons I've ever heard is between what Ezra the priest and Nehemiah the official did in response to finding out about the men of Judah marrying these foreign women. In response, Ezra tore his own robes. Nehemiah tore the robes of the offenders. It's a good balance. The priest went in repentance before God, identifying himself in intercession for the people of God. The government leader held people accountable for their treachery.