The temple in Jerusalem began as an idea by King David:
1 Now it came about when the king lived in his house, and the LORD had given him rest on every side from all his enemies, 2 that the king said to Nathan the prophet, "See now, I dwell in a house of cedar, but the ark of God dwells within tent curtains." 3 Nathan said to the king, "Go, do all that is in your mind, for the LORD is with you." (2Samuel 7:1-3, NASB)
Although God allowed David to gather materials for his house in Jerusalem, he did not want him to build it. One of David's sons would build God's house of prayer.
7 David said to him, “Son, I wanted to build a temple to honor the Lord my God. 8 But the Lord told me that I had killed too many people and fought too many wars.
9 He did, however, make me a promise. He said, ‘You will have a son who will rule in peace, because I will give him peace from all his enemies. His name will be Solomon, because during his reign I will give Israel peace and security. 10 He will build a temple for me ” (1Chronicles 22:7-10, TEV)
Work was begun around 966 - 965 B.C. and was completed around 959 - 958 B.C. The building was built on Mount Moriah, which is east of the city, on the spot where Isaac was offered by Abraham (Genesis 22:1-14). Unfortunately, the building was burned, pillaged and destroyed by King Nebuchadnezzar of Babylon in 586 B.C. He carried all its treasures back to Babylon.
The second (Herod's) temple in Jerusalem was built on the same location as the first. When Herod the Great became king of Judea "God's house" had stood for roughly 500 years, and had suffered considerably from natural decay as well as from the assaults of hostile armies. He began the work of rebuilding around 20 B.C., which was carried out at an enormous cost of labor and expense, and on a scale of surpassing splendor. Work on the building was still going on at the time of Jesus (John 2:16, John 2:19-21). It was finally completed in 65 A.D.
A few short years later Roman legions took Jerusalem by storm, and notwithstanding the strenuous efforts General (later Emperor) Titus made to preserve it, his soldiers set it on fire in several places. The temple's total destruction began on the 9th of Ab, the same day its first destruction occurred. Its demise was completed on Ab 10, which corresponds to Sunday, August 5th in 70 A.D.