As we begin a new book of the Bible it is important to know where we are historically in this book. A great link which gives you some background can be found here: https://www.esv.org/resources/esv-global-study-bible/introduction-to-ezra/
I find it amazing that the leader of a pagan nation would allow the Israelites to go free after years of captivity. Granted that the captivity was under the Babylonians and that the Persians had just conquered the Babylonians so this people were not really their people. But it goes further than that. The king of Persia, Cyrus, is said to have his spirit stirred by the Lord. As a result he not only lets the people go but gives them a particular task which is to rebuild the temple of the Lord. Now Ezra may have written this book of the Bible but he was not alive when this happened. According to the timeline on the link above he does not enter Jerusalem until 458 BC and Cyrus gives out his decree in 586.
The people of Israel were exiles and were brought out of Babylon, which is now Persia in this writing, and sent to Jerusalem not only to inhabit it but actually primarily to rebuild the temple. The entire book of Ezra is a recounting of this building. In this portion the king of a foreign nation, a pagan king at that, takes the initiative in ensuring that the work of the Lord be done.