Moshe had gone up in the Month of Sivan, and returned after forty days and forty nights, on the 17th of Tammuz with the First Luchos. When Moshe observed the Jewish People sinning by creating and worshipping the Golden Calf, and participating in other sinful activities centered around the worship of that idol, he broke that first set of Luchos. He ascended Mount Sinai a second time, on the eighteenth day of Tammuz, the day after the great sin, and remained there for another forty days and forty nights, praying to G-d to spare the Jewish People and to return His full Presence among them.

At the conclusion of the second forty day and forty night period (that is, on the 29th of Av, Erev Rosh Chodesh Elul), G-d forgave the Jewish People and instructed Moshe to ascend Har Sinai yet again the next day, to receive the Second Luchos, on which would be inscribed for the second time the Ten Commandments. Moshe’s ascension to Har Sinai for the third time (which also took forty days and forty nights, ending on Yom Kippur) occurred on Rosh Chodesh Elul.

HaShem also restored His Presence to the Jewish People by authorizing the construction of the “Mishkan,” the Temporary Structure which served as a “Residence,” so to speak, for the Divine Presence, before the building of the First Temple in Jerusalem.