A number of Old Testament scriptures speak of the Messiah and make it plain that he will not only restore the kingdom of Israel, but he will also restore the Temple. For example, Haggai 2:6-7 and 22-23  make it clear that Haggai’s prophecy is not only about the return of Israel from Babylon, but also eschatological, concerned with the coming of the Messiah. Thus, as did pre-Christian, post-exilic Jews, we can read Haggai’s discussion of the restoration of the Temple and of the Lord coming to his Temple (for example Haggai 1:8) not only as a prophecy about the return from Babylon, but also as describing what the Jews expected to happen with the coming of the Messiah: the Temple would be restored and the Messiah would come to it.
Perhaps no scripture could be read as a messianic prophecy of the Temple more than Zechariah 6:12-13:
Behold the man whose name is The Branch; and he shall grow up out of his place, and he shall build the temple of the Lord: Even he shall build the temple of the Lord; and he shall bear the glory, and shall sit and rule upon his throne; and he shall be a priest upon his throne: and the counsel of peace shall be between them both.
Passages such as these show that, for those waiting for the Messiah at the time of Jesus’s birth, the expectation was that he would be a priest-king who would build (or restore) the Temple just as he would institute (or restore) the kingdom of Israel.
We see a similar expectation in The Testament of the Twelve Patriarchs, specifically in the Testament of Levi 17-18. Though the textual history of The Testament is, as one commentary says, “Byzantine,”  and though chapters 17 and 18 show redaction by a Christian editor or interpolater, those chapters also reflect pre-Christian ideas and messianic understandings. In 17:8 through 18:1, the Testament of Levi describes an apostasy, and it describes that apostasy as a corruption of the priesthood . Then, verses two through three in chapter eighteen describe the restoration of the priesthood in a new priest-king. Even if, as some argue, the verses in question are Christian rather than pre-Christian, they show two things: first, that apostasy was understood as the corruption of the priesthood and, second, that the Messiah was understood as a priest-king who would restore the priesthood. 
Judah’s history also prepared them to see the Messiah as bringing a restoration of temple worship. That history specifically explains why the promise to Zachariah of a Messiah would come as a promise to restore the temple cult. The history of disputes over the Temple begins at least with the return from exile in Babylon. As we see in Ezra 5, on the return from Babylon there was considerable debate about who could participate in rebuilding the Temple and who had appropriate priesthood. This dispute resulted in the creation of a “new” group composed of those who had stayed in the Jerusalem area during the exile and who are seen by the exiles as unclean, those who came to be called the Samaritans. Subsequent history created even more factions in this dispute.
After the death of Alexander the Great in 323 B.C. and the consequent breakup of his kingdom, a number of Alexander’s generals established empires in the resulting parts. Among them were the Ptolemies in Egypt and the Seleucids in Syria. Judea was dominated by the Ptolemies until 198 , when the Ptolemies lost a battle to the Seleucids near what, in the Gospels, is called Caesarea Philippi. With that battle, Judea changed hands. But neither the Ptolemies nor the Seleucids were heavily involved in Judean politics; the Jews had considerable autonomy and were, essentially, a religious state ruled by the law of the Pentateuch and the high priest of the Temple, a descendant of Zadok, the high priest in Solomon’s Temple.
Under the domination of these two states, the Ptolemies and the Seleucids, each with a fundamentally Greek culture, there was considerable pressure to “Hellenize,” pressure for what today we would call modernization: the most up-to-date laws and political systems (in other words Greek law and politics), schools with the latest educational methods focusing on the latest knowledge (in other words, Greek schools in the Greek language), as well as participation in the wider Hellenic economy. The temple priests collaborated with the Ptolemies and Seleucids in the attempt to Hellenize Israel, perhaps at least partly as a defensive measure. Perhaps they thought, “The Seleucids will leave us alone if we are Hellenized.” However, not long after the change from Ptolemaic domination to Seleucid domination, Jason, the brother of Onias III, the legitimate high priest, offered the Seleucid king, Antiochus IV , a bribe if he would make Jason the reigning high priest in Onias III’s place. The king needed the money to pay heavy taxes he owed to the Romans and Jason was an ardent Hellenizer, so Antiochus IV accepted the bribe and made Jason the high priest. A few years later, Menelaus, who was even more interested in Hellenizing Israel than Jason had been, offered a larger bribe if Antiochus IV would make him high priest in Jason’s placeâ€”even though Menelaus was not a descendent of Zadok. Antiochus IV accepted the bribe and made Menelaus high priest in 171.
In 168, Israelites loyal to their religion tried to oust Menelaus and reinstall Jason, but Antiochus IV interpreted this attempt as rebellion against his rule, though it seems not to have been, and he laid Jerusalem waste, destroying its walls, looting the temple treasury, banning Jewish religious practices, and giving Judea a Hellenistic government. Retaining Menelaus as the high priest, Antiochus IV defiled the Temple by sacrificing a pig on the altar, and he converted the Temple into a temple for Zeus, which it was for three years, from the end of 167 to the end of 164. The result of this attack on Jerusalem and the desecration of the Temple was full-scale revolt led by the Hasmonean priestly family of Mattathias and his five sons. In 164, the revolutionaries won the right to practice Judaism, and they purified the Temple and resumed temple worship. In 142, they won full autonomy: “they recovered the law out of the hand of the Gentiles, and out of the hand of kings, neither suffered they the sinner to triumph” (2 Maccabees 2:48).
Since those of the legitimate, Zadokite priesthood lineage had fled to Egypt when Onias III was replaced by Jason (setting up a temple in Leontopolis), after the Hasmonean revolt it was impossible to have a high priest from the Zadokite family. Instead, first Jonathan, son of Mattathias, accepted the high-priest’s position from the Seleucids (in 152). Then, after Jonathan was captured and executed in 143, Simon, the last of Mattathias’s sons, was elected “governor and high priest for ever, until there should arise a faithful prophet” (1 Maccabees 14:41; my emphasis), though the Hasmonean family was not the family from which the high priest was to be chosen. The Hasmoneans held the position of high priest until the destruction of the Temple (70 AD) .
The reaction to these events was varied. Some, such as the Pharisees, went along with the election of Simon, though grudgingly. Others, such as the community at Qumran, protested by leaving Jerusalem completely.
The Pharisees gradually coalesced over time to become one of the most powerful groups in Judea, but their origin is unclear. (The word pharisee probably originally meant “separatist.”) They seem to have been a response to the difficulties of this period, including and perhaps especially the difficulties with the high priest, but perhaps starting as early as the return from Babylon. The priesthood of the Temple had been corrupted and its restoration under Simon was far from unambiguous. There were many Hellenizers in Judea, encouraged by official policy, so Judaism seemed in danger of disappearing in the melting-pot of Hellenic culture. Looking to strengthen Israel, groups of people gathered together to encourage one another, and in the absence of full faith in the temple practices, they turned their devotion to the Law, building on already existing tendencies among some  and turning their attention from righteousness exhibited in Temple ritual to righteousness exhibited in adherence to the Mosaic Law.
By the time of Christ, the Pharisees were a full-fledged political and religious party with a fully-developed oral tradition supplementing the Mosaic Law. By then, the Pharisees vied with the Sadducees (another way of saying “Zadokites,” the party of the Hasmonean rulers) for political authority in Judea, and they had considerable power and influence, though contrary to the way we often think of them, they were not, in and of themselves, the rulers in Israel.
1. This began life as a few paragraphs from a longer essay on the New Testament concept of apostasy. I am heavily indebted to the first part of F. F. Bruce, New Testament History (New York: Anchor, 1972).
2. “For thus saith the Lord of hosts; Yet once, it is a little while, and I will shake the heavens, and the earth, and the sea, and the dry land; And I will shake all nations, and the desire of all nations shall come: and I will fill this house with glory, saith the Lord of hosts. [. . .] And I will overthrow the throne of kingdoms, and I will destroy the strength of the kingdoms of the heathen; and I will overthrow the chariots, and those that ride in them; and the horses and their riders shall come down, every one by the sword of his brother. In that day, saith the Lord of hosts, will I take thee, O Zerubbabel, my servant, the son of Shealtiel, saith the Lord, and will make thee as a signet: for I have chosen thee, saith the Lord of hosts.”
3. H. W. Hollander & M. De Jonge, The Testaments of the Twelve Patriarchs: A Commentary (Leiden: E. J. Brill, 1985), 2.
4. Robert J. Kugler, The Testaments of the Twelve Patriarchs (Sheffield: Sheffield Academic Press, 2001), 47-52.
5. If these passages are Christian rather than pre-Christian, they show not just that the Temple and the priesthood were important during the intertestamental period, but that they were probably a part of Christian understanding as well. If these passages are the result of Christian redaction, they show that the concern for priesthood and Temple was a part of Christian and not only pre-Christian thinking.
6. Antiochus IV is also called Antiochus Epiphanes, a title that suggested that he was a manifestation of Zeus on earth.
7. The section on “Chronology” in the LDS Bible Dictionary has a time line of these events that may be useful.
8. Bruce suggests that Malachi (450 B.C.) describes these tendencies in Israel already at a much earlier time: wide-spread inattention to the Law, with a few groups of those who remain faithful. (See Malachi 3:13-16.) I believe we see signs of the changes that precipitated these difficulties in Nehemiah 8:4-8, when Ezra reads the Law to the people: the scribe has taken precedence over the priest (though Ezra is also a priest), and the reading and interpretation of the law (verse 8 ) is, I believe, mentioned for the first time, though it later comes to occupy center stage in Israelite-Jewish culture.