The people of Israel were conquered by Babylon because they broke their covenant with God through idolatry and injustice. The book of Haggai was written 70 years after this prophesied exile and recounts the experience of a small group of Israelites, led by Joshua and Zerubbabel, who had returned to rebuild Jerusalem. Haggai challenges them to remember their covenant, remain faithful to God and build the temple before constructing their own homes.
While the new temple didn't meet their expectations, their efforts and faithfulness would be blessed. They could also be encouraged by God's promise to build a New Jerusalem for His international kingdom, defeat evil, and live in their midst. Future prophetic books contain more details about when these promises would be fulfilled.