Ezra and Nehemiah are books about coming home. However, homecomings can be more difficult than expected, even disappointing in some ways. You know, like when you came home from summer camp to find your parents had turned your bedroom into an office with a treadmill desk and now you have to share a room with your annoying little brother. Ezra and Nehemiah are concerned with creating an ideal home but this means making a lot of changes: forcing people not to work on the Sabbath, rebuilding the city, and condemning mixed marriages. It's not exactly the glorified return to Jerusalem that all the Major Prophets were talking about.
Plus, by the time the exiles got back to Judea, it had become home to lots of other people, including the poorer Judeans who were allowed by Babylon to stay behind, as well as other tribes like the Not-So-Good Samaritans. They made life difficult for the exiles. The Samaritans knew that a brand-new Temple in Jerusalem would draw Jews from all over, which would threaten their control of their own lands. So they tried everything to stop the building.
In these books, the people and their leaders are very concerned with reminding themselves of who they are and where they come from. During this vulnerable time in Jewish history, Ezra and Nehemiah know it's important to develop a strong religious identity among the people if they're going to survive.
But how to do it? Well, kick out all foreign wives and children; keep rebuilding the Temple; celebrate the Sabbath and other holidays mentioned in the Torah; and restore Mosaic law as the basis for stabilizing the life of the community. And be really, really, serious about it.
The Jews had to guard their identity because they were a small and vulnerable nation, still in the rebuilding stage and surrounded by hostile nations. Exposure to foreign tribes could be pretty dangerous at this stage of the game. Persia, on the other hand, had no such problem. They were such a powerful empire that the emperor could allow, even encourage, the Jewish exiles to go home and establish their own kingdom and live by the rules of their own God.
According to the Bible, the Israelites have had a bad habit of sliding back into idolatry and other disloyalty to God despite the threat of serious punishment: total annihilation, famine, foreign invasions, locust armies, people reduced to eating their children—you know, stuff like that. It never seemed to work. But in Ezra and Nehemiah, an epidemic of loyalty and obedience is breaking out. This time, they're listening. What's up with that?
Ezra and Nehemiah are nothing if not relentless. Nobody's making it easy for them to rebuild the temple or institute rules for the community. The Samaritans and others keep butting in and shutting things down and turning the king against the Israelites. The people do absolutely awful things like marry foreign women and raise children who don't speak the language. They have to be constantly on guard while building, with no time for coffee breaks or bathing. The perseverance pays off, though. Nobody passes out from the hot and sweaty atmosphere, the temple gets built and dedicated, the city walls repaired, and the king approves and buys the supplies.
You could also say that the Jews in Babylon persevered during the exile, but to be honest, they lived pretty well there. The first generation of exiles missed home, but their descendants got used to living in prosperous Babylon. Not everyone came back to Judea or even wanted to. For them, the perseverance part was maintaining their religious identity during those generations until they returned home.
Nehemiah, Ezra, and God all love rules—613 of them, to be exact. In fact, aside from the actual physical rebuilding of Jerusalem, the re-institution of the Mosaic laws and rituals is the main objective of Ezra and Nehemiah.
Since God isn't showing up to eat and chat like he did in Abraham's day, the people experience him by obeying his laws. It wasn't all that long ago that prophets like Ezekiel and Jeremiah were de-emphasizing the role of Temple ritual and focusing more on God's expectations for ethical behavior. That was easier to do when there was no temple and the people were in exile. Now that they're back, this stuff matters again. Plus, since these rituals and laws were to be unique to the Israelite community; it was a nation-building exercise. After this, all other people recognized the Jews as people who had certain rules—they observed the Sabbath, only ate certain foods, didn't intermarry, only worshipped one God, etc. (source). (In this sense, Ezra's reforms were very successful in making the community distinct.)