Then Jeshua son of Jozadak, with his fellow priests, and Zerubbabel son of Shealtiel with his kin set out to build the altar of the God of Israel, to offer burnt offerings on it, as prescribed in the law of Moses the man of God. They set up the altar on its foundation, because they were in dread of the neighboring peoples, and they offered burnt offerings upon it to the Lord, morning and evening. And they kept the festival of booths, as prescribed, and offered the daily burnt offerings by number according to the ordinance, as required for each day. (NRSV Ezra 3:2-4)
Then stood up Jeshua the son of Jozadak, and his brethren the priests, and Zerubbabel the son of Shealtiel, and his brethren, and builded the altar of the God of Israel, to offer burnt offerings thereon, as it is written in the law of Moses the man of God. And they set the altar upon his bases; for fear was upon them because of the people of those countries: and they offered burnt offerings thereon unto the Lord, even burnt offerings morning and evening. They kept also the feast of tabernacles, as it is written, and offered the daily burnt offerings by number, according to the custom, as the duty of every day required. (KJV Ezra 3:2-4)
The most obvious way of expressing loyalty to God in the worship tradition of that time is by sacrificing to him. The first group of returned exiles was also living in fear of the surrounding tribes, so they were sacrificing day and night in hopes this would offer some protection. Maybe fear is the motivation here, not loyalty, although a lot of rulers enforce loyalty by scaring the heck out of their people.
The people of Israel, the priests and the Levites, and the rest of the returned exiles, celebrated the dedication of this house of God with joy. They offered at the dedication of this house of God one hundred bulls, two hundred rams, four hundred lambs, and as a sin offering for all Israel, twelve male goats, according to the number of the tribes of Israel. Then they set the priests in their divisions and the Levites in their courses for the service of God at Jerusalem, as it is written in the book of Moses. (NRSV Ezra 6:16-18)
And the children of Israel, the priests, and the Levites, and the rest of the children of the captivity, kept the dedication of this house of God with joy. And offered at the dedication of this house of God an hundred bullocks, two hundred rams, four hundred lambs; and for a sin offering for all Israel, twelve he goats, according to the number of the tribes of Israel. And they set the priests in their divisions, and the Levites in their courses, for the service of God, which is at Jerusalem; as it is written in the book of Moses. (KJV Ezra 6:16-18)
The Law of Moses—the Torah—is the new standard for behavior. Since this is an ancient set of laws (about six or seven hundred years old by that time) that sealed the covenant between God and Israel, sticking to these rules is now the ultimate sign of loyalty.
Then I proclaimed a fast there, at the river Ahava, that we might deny ourselves before our God, to seek from him a safe journey for ourselves, our children, and all our possessions. For I was ashamed to ask the king for a band of soldiers and cavalry to protect us against the enemy on our way, since we had told the king that the hand of our God is gracious to all who seek him, but his power and his wrath are against all who forsake him. So we fasted and petitioned our God for this, and he listened to our entreaty. (NRSV Ezra 8:21-23)
Then I proclaimed a fast there, at the river of Ahava, that we might afflict ourselves before our God, to seek of him a right way for us, and for our little ones, and for all our substance. For I was ashamed to require of the king a band of soldiers and horsemen to help us against the enemy in the way: because we had spoken unto the king, saying, The hand of our God is upon all them for good that seek him; but his power and his wrath is against all them that forsake him. So we fasted and besought our God for this: and he was intreated of us. (KJV Ezra 8:21-23)
Like sacrificing, fasting is another way of demonstrating loyalty and commitment to God. You're giving up something that's of use to you, in order to obtain higher gains. Ezra has faith that fasting will demonstrate to God that he's worthy of protection from ambush by the local tribes.
But now for a brief moment favor has been shown by the Lord our God, who has left us a remnant, and given us a stake in his holy place, in order that he may brighten our eyes and grant us a little sustenance in our slavery. For we are slaves; yet our God has not forsaken us in our slavery, but has extended to us his steadfast love before the kings of Persia, to give us new life to set up the house of our God, to repair its ruins, and to give us a wall in Judea and Jerusalem. (NRSV Ezra 9:8-9)
And now for a little space grace hath been shewed from the Lord our God, to leave us a remnant to escape, and to give us a nail in his holy place, that our God may lighten our eyes, and give us a little reviving in our bondage. For we were bondmen; yet our God hath not forsaken us in our bondage, but hath extended mercy unto us in the sight of the kings of Persia, to give us a reviving, to set up the house of our God, and to repair the desolations thereof, and to give us a wall in Judah and in Jerusalem. (KJV Ezra 9:8-9)
Ezra says that they need to be loyal to God because God, by freeing them from exile, has actually remained loyal to them. He may have destroyed Jerusalem and sent them off to exile in Babylon and Assyria, but he hasn't forgotten them completely.
Then Ezra withdrew from before the house of God, and went to the chamber of Jehohanan son of Eliashib, where he spent the night. He did not eat bread or drink water, for he was mourning over the faithlessness of the exiles. They made a proclamation throughout Judah and Jerusalem to all the returned exiles that they should assemble at Jerusalem, and that if any did not come within three days, by order of the officials and the elders all their property should be forfeited, and they themselves banned from the congregation of the exiles. (NRSV Ezra 10:6-8)
Then Ezra rose up from before the house of God, and went into the chamber of Johanan the son of Eliashib: and when he came thither, he did eat no bread, nor drink water: for he mourned because of the transgression of them that had been carried away. And they made proclamation throughout Judah and Jerusalem unto all the children of the captivity, that they should gather themselves together unto Jerusalem; And that whosoever would not come within three days, according to the counsel of the princes and the elders, all his substance should be forfeited, and himself separated from the congregation of those that had been carried away. (KJV Ezra 10:6-8)
Ezra's making the people take a loyalty oath or face separation of the community. He's already shown that he's serious about kicking people out, because he's just done that to the foreign wives and children. The people must realize that being cast out from the community would put them at serious risk in this environment, because they all show up on time. When has that ever happened?
Remember the word that you commanded your servant Moses, "If you are unfaithful, I will scatter you among the peoples; but if you return to me and keep my commandments and do them, though your outcasts are under the farthest skies, I will gather them from there and bring them to the place at which I have chosen to establish my name." They are your servants and your people, whom you redeemed by your great power and your strong hand. O Lord, let your ear be attentive to the prayer of your servant, and to the prayer of your servants who delight in revering your name. Give success to your servant today, and grant him mercy in the sight of this man! At the time, I was cupbearer to the king. (NRSV Nehemiah 1:8-11)
Remember, I beseech thee, the word that thou commandedst thy servant Moses, saying, If ye transgress, I will scatter you abroad among the nations: But if ye turn unto me, and keep my commandments, and do them; though there were of you cast out unto the uttermost part of the heaven, yet will I gather them from thence, and will bring them unto the place that I have chosen to set my name there. Now these are thy servants and thy people, whom thou hast redeemed by thy great power, and by thy strong hand. O Lord, I beseech thee, let now thine ear be attentive to the prayer of thy servant, and to the prayer of thy servants, who desire to fear thy name: and prosper, I pray thee, thy servant this day, and grant him mercy in the sight of this man. For I was the king's cupbearer. (KJV Nehemiah 1:8-11)
Here's a clear statement about the consequences of disloyalty vs. loyalty: exile vs. home in Judah. Nehemiah is telling God that he hopes God remembers what he promised, including letting the people know how to pronounce "commandedst."
Now therefore, our God—the great and mighty and awesome God, keeping covenant and steadfast love—do not treat lightly all the hardship that has come upon us, upon our kings, our officials, our priests, our prophets, our ancestors, and all your people, since the time of the kings of Assyria until today. You have been just in all that has come upon us, for you have dealt faithfully and we have acted wickedly; our kings, our officials, our priests, and our ancestors have not kept your law or heeded the commandments and the warnings that you gave them. (NRSV Nehemiah 9:32-34)
Now therefore, our God, the great, the mighty, and the terrible God, who keepest covenant and mercy, let not all the trouble seem little before thee, that hath come upon us, on our kings, on our princes, and on our priests, and on our prophets, and on our fathers, and on all thy people, since the time of the kings of Assyria unto this day. Howbeit thou art just in all that is brought upon us; for thou hast done right, but we have done wickedly: Neither have our kings, our princes, our priests, nor our fathers, kept thy law, nor hearkened unto thy commandments and thy testimonies, wherewith thou didst testify against them. (KJV Nehemiah 9:32-34)
Ezra confesses that the disloyalty is really all on Israel's side, that God's actually been more merciful and loyal than the people deserved. They only got what was coming to them because of their disobedience, but the great and powerful Oz—sorry, we meant God—didn't forget the covenant.
Here we are, slaves to this day—slaves in the land that you gave to our ancestors to enjoy its fruit and its good gifts. Its rich yield goes to the kings whom you have set over us because of our sins; they have power also over our bodies and over our livestock at their pleasure, and we are in great distress. Because of all this we make a firm agreement in writing and on that sealed document are inscribed the names of our officials, our Levites, and our priests. (NRSV Nehemiah 9:36-38)
Behold, we are servants this day, and for the land that thou gavest unto our fathers to eat the fruit thereof and the good thereof, behold, we are servants in it: And it yieldeth much increase unto the kings whom thou hast set over us because of our sins: also they have dominion over our bodies, and over our cattle, at their pleasure, and we are in great distress. And because of all this we make a sure covenant, and write it; and our princes, Levites, and priests, seal unto it. (KJV Nehemiah 9:36-38)
Ezra is saying that this time they really mean it. He makes everyone put the promises in writing and has the priests put their stamp of approval on it. This rededication to Mosaic Law is a huge milestone in revitalizing the Israelite nation. Of course, we're talking about Ezra's interpretation of Mosaic Law here. Since he's considered a major editor and compiler of the Biblical canon, he puts his own spin on it.