As explained in previous chapter notes (see notes for 2 Chronicles 36, Ezra 1-4 and Ezra 5-7), the return of the people of Judah to Jerusalem was done in stages, under varying political circumstances as the Persian empire (see Ancient Empires - Persia) became the master of the Middle East in place of the Babylonian empire (see Ancient Empires - Babylon) that had taken Judah into captivity by 586 BC. As with their return, their captivity was also done in stages, allowing the people a very generous opportunity to repent of their idolatry before it was too late, warnings that they defiantly ignored - see Why Babylon?.
The approximate dates of the buildup of the return:
536 BC: Zerubbabel (Ezra Chapter 2). The prophets Zechariah and Haggai (and others) were active at that time.
Ezra's arrival to Jerusalem from "the river Ahava" in Mesopotamia (likely a tributary of the Euphrates River in what is today Iraq):
"Then we departed from the river Ahava on the twelfth day of the first month, to go to Jerusalem; the hand of our God was upon us, and he delivered us from the hand of the enemy and from ambushes by the way. We came to Jerusalem, and there we remained three days." (Ezra 8:31-32 RSV)
As a scribe (from which we get the term "lawyer" - see Scribes), Ezra carefully composed an accounting of all of the people and artifacts.
"On the fourth day, within the house of our God, the Silver and the Gold and the Vessels were weighed into the hands of Meremoth the priest, son of Uriah, and with him was Eleazar the son of Phinehas [see The Lines Of Eleazar and Ithamar], and with them were the Levites, Jozabad the son of Jeshua and Noadiah the son of Binnui. The whole was counted and weighed, and the weight of everything was recorded. At that time those who had come from captivity, the returned exiles, offered burnt offerings to the God of Israel, twelve bulls for all Israel, ninety-six rams, seventy-seven lambs, and as a sin offering twelve he-goats; all this was a burnt offering to The Lord. They also delivered the king's commissions to the king's Satraps and to the governors of the province Beyond the River; and they aided the people and the house of God." (Ezra 8:33-36 RSV)
Ezra Chapter 9
The Lord's command against intermarriage was based upon when it could, but not always have (e.g. Moses married a "foreign" woman, Numbers 12:1) a corrupting religious effect upon the people of God (e.g. see Solomon's Compromise). It was not "racist" because most of the Israelites were, and are, descended from, among others, the people of Iraq (see Israel's Iraqi Roots), Syria (e.g. the Israelite mothers Rebekah, Rachel and Leah were all themselves Syrian by birth), Egypt (e.g. the Israelite patriarchs Ephraim and Manasseh had an Egyptian mother), Moab (Ruth, a key ancestor of King David was from Moab - see notes for Ruth 1-3 and Ruth 4, 1 Samuel 1-2) and Midian (Moses' sons were born from his first wife Zipporah of Midian). See also Nativity.
Ezra's proclamation against intermarriage at the time of their return from the Babylonian captivity was to prevent the people from returning to idolatry, the religious unfaithfulness that had been the cause of their being sent into the Babylonian captivity (unfortunately, some of the people of Judah, rather than simply obeying the Law of God, from that point on began adding their own traditions to God's Law, presumptuous "traditions of men" that sometimes even eclipsed God's true Law - the reason that, centuries later, Jesus Christ rebuked them after they blasphemously accused Him of breaking God's Law - see Did Jesus Break The Law?).
"After these things had been done, the officials approached me and said, "The people of Israel and the priests and the Levites have not separated themselves from the peoples of the lands with their abominations, from the Canaanites, the Hittites, the Perizzites, the Jebusites, the Ammonites, the Moabites, the Egyptians, and the Amorites. For they have taken some of their daughters to be wives for themselves and for their sons; so that the holy race has mixed itself with the peoples of the lands. And in this faithlessness the hand of the officials and chief men has been foremost." (Ezra 9:1-2 RSV)
Ezra Chapter 10
Ezra's portion of Bible History ends with the people's dedication to obey God by separating themselves from unconverted spouses, while keeping in mind that even ancient Israel, apart from the reality that Israelites originated from the foreign nations around them (see links above), accepted anyone who turned from paganism to the worship of the only true God e.g. some Egyptians took part in the Exodus out of Egypt with the Israelites ("a mixed multitude also went up with them," Exodus 12:38 RSV).
While Ezra prayed and made confession, weeping and casting himself down before the house of God, a very great assembly of men, women, and children, gathered to him out of Israel; for the people wept bitterly. And Shecaniah the son of Jehiel, of the sons of Elam, addressed Ezra: "We have broken faith with our God and have married foreign women from the peoples of the land, but even now there is hope for Israel in spite of this. Therefore let us make a covenant with our God to put away all these wives and their children, according to the counsel of my lord and of those who tremble at the commandment of our God; and let it be done according to the law. Arise, for it is your task, and we are with you; be strong and do it."
Fact Finder: Did Jesus Christ accept "foreigners," such as the Samaritans, in Israel? Ironically, did many of the Samaritans recognize Jesus as the Messiah, while many of His fellow Jews rejected Him?