Under Law, the focus is not only on moral but also physical purity - in this case ethnical purity was equivalent to ethical purity. The Law has stipulated that Israelites were not to take foreign wives. In Deuteronomy 7:3-4 Moses writes: "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 sons away from following me to serve other gods, and the Lord's anger will burn against you and will quickly destroy you." Moses' concern here regarding intermarriage is not ethnical but ethical--that intermarriage may result in the Israelites turning away from the Lord to worship the Canaanite gods, which will lead to moral and spiritual corruption. We have to differentiate ends from means. There has been exception to this rule--consider Ruth, a foreign wife of Boaz. Though ethnically a Moabite, her moral and spiritual allegiance was to the God of Israel: "Don't urge me to leave you or to turn back from you. Where you go I will go, and where you stay I will stay. Your people will be my people and your God my God" (Ruth 1:16). Not only was Ruth accepted by the Israelites, she became the ancestors of David who was the ancestor of Christ.
However, for Ezra who was unaccustomed to seeing intermarriages while in exile, it was horrendous. He could not separate ethnical purity from ethical purity--to him, they are the same. And as a general principle, it is valid. But there are exceptions to this general principle even in the New Testament. Even for those who believe that it is a sin to be "unequally yoked with unbelievers" (2 Cor 6:14), there is also a counter-balancing principle in 1 Cor 7:14 which says that "the unbelieving husband has been sanctified through his wife, and the unbelieving wife has been sanctified through her believing husband. Otherwise your children would be unclean, but as it is, they are holy." In other words, this principle can work both way -- the believing spouse can be led astray to worship the gods of the unbelieving partner or the unbelieving partner can be led into the worship of the true God through the believing spouse. In fact, Paul is saying here that the unbelieving spouse and the children are made "holy", meaning set apart because of the believing spouse and parent. The OT Law is focused on preventing evil but the NT Spirit is focused on promoting good. So in the same vein Peter writes: "Wives, in the same way be submissive to your husbands so that, if any of them do not believe the word, they may be won over without words by the behavior of their wives, when they see the purity and reverence of your lives." In the OT, the covenant of Moses was only for the Jews and therefore exclusive; but in the NT, the covenant of Christ is for all and therefore inclusive. Grace will triumph over Law even in such cases.
Ezra lived under the Law and the Law is exclusive -- only for Jews. However, for us who live under Grace, we should have a more inclusive attitude---even those who are now currently outside the covenant can one day be included through faith in Christ. No one who is married to a non-believing spouse needs to feel they are living "in sin" because we are told in John 3:16 that "God so loved the world" (and the "world" includes our unbelieving spouses).
Father, we thank You that the Grace of our Lord Jesus is inclusive not exclusive because the Gospel is both Jews and Gentiles. Help us to believe that through You we sanctify every relationship we have because of Your indwelling Spirit. Amen.