The temple in Jerusalem began as an idea of King David. Although he wanted to build it, God only allowed him to gather building materials for it. It would be left to David's son Solomon to construct the house of God in Jerusalem:
"But it happened that night that the word of the Lord came to Nathan, saying, 'Go and tell My servant David, 'Thus says the Lord: "Would you build a house for Me to dwell in? For I have not dwelt in a house since the time that I brought the children of Israel up from Egypt, even to this day, but have moved about in a tent and in a tabernacle . . . " ' '
"'When your days are fulfilled and you rest with your fathers, I will set up your seed after you, who will come from your body, and I will establish his kingdom. HE SHALL BUILD A HOUSE FOR MY NAME . . . ' " (2Samuel 7:4-6, 12-13, NKJV throughout)
David confided with a young Solomon as to why God did not allow him to build the temple:
" . . . And David said to Solomon: 'My son, as for me, it was in my mind to build a house to the name of the Lord my God; but the word of the Lord came to me, saying, "You have shed much blood and have made great wars; you shall not build a house for My name, BECAUSE YOU HAVE SHED MUCH BLOOD ON THE EARTH IN MY SIGHT. " (1Chronicles 22:6-8)
Solomon began his reign over Israel in 970 B.C. and began work on the temple four years later (966 - 965 B.C.). He built "the house of God" on the summit of Mount Moriah (1Chronicles 22:14, 29:4; 2Chronicles 3:1), on the east of Jerusalem where Abraham was to offer up Isaac (Genesis 22:1-14). The structure was completed in 959 - 958 B.C.
After Solomon's death Israel split into two major pieces - the Northern Ten Tribes of Israel and the Kingdom of Judah. The Northern kingdom lasted until 723 B.C. The kingdom of Judah lasted until 586 B.C. when it was conquered by Babylon. It was Babylon's King Nebuchadnezzar who burned, pillaged and destroyed the temple in Jerusalem (2Kings 24:13; 2Chronicles 36:7) and carried all of its treasures away to Babylon.
What is known as the second (or Herod's) temple was built in the same location as the first. The foundations were laid about 535 B.C. by Jewish exiles returning from Babylon. When Herod the Great became king of Judea the unfinished structure had stood for about five hundred years. Herod, desirous of gaining the favor of the Jews, proposed to rebuild it. Work on restoring the house of God was begun and carried out at great labor and expense, and on a scale of surpassing splendor.
Ultimately, the need for an earthly sanctuary in Jerusalem was fulfilled and brought to completion by the sacrifice of Jesus Christ, which ended the Old Covenant and the need for a physical priesthood. Under the New Covenant, the spiritual temple of God is in heaven where Jesus Christ is High Priest and has superseded any physical one on earth.