On the seventh day after the Ten Commandments Moshe went up on the mountain, as it says "The Presence of the LORD abode on Mount Sinai, and the cloud hid it for six days..." (Shemot 24:16) This was in order for Moshe to purify himself. "On the seventh day He called to Moses from the midst of the cloud." (ibid.) "Moses went inside the cloud and ascended the mountain; and Moses remained on the mountain forty days and forty nights." (Shemot 24:18) On the 17th of Tammuz he came down and shattered the tablets, "The next day Moses said to the people, “You have been guilty of a great sin. Yet I will now go up to the LORD; perhaps I may win forgiveness for your sin.” Moshe went back up on the 18th of Tammuz and pleaded for mercy on behalf of Israel, as it is written "When I lay prostrate before the LORD those forty days and forty nights, because the LORD was determined to destroy you," (Devarim 9:25) At that moment, the Holy One once again viewed Israel with favor and said to Moshe to carve new tablets and to come up the mountain once again, as it says "Thereupon the LORD said to me, “Carve out two tablets of stone like the first, and come up to Me on the mountain; and make an ark of wood." (Devarim 10:1) He came down on the 28th of Av and carved the second tablets, as it says "So Moses carved two tablets of stone, like the first, and early in the morning he went up on Mount Sinai..." (Shemot 34:4) He went back up on the 29th of Av and the Torah was repeated to him a second time, as it says "I had stayed on the mountain, as I did the first time, forty days and forty nights; and the LORD heeded me once again: the LORD agreed not to destroy you." (Devarim 10:10) 'As I did the first time,' just as the first was a time of favor, so too the second were a time of favor- we can derive from this that those in the middle were a time of anger. He came down on the 10th of Tishre, which was Yom Kippur, and announced to them that they had found favor before God (Hamakom), as it says "Pardon our iniquity and our sin, and take us for Your own!” (Shemot 34:9) Therefore it was established as a fixed day and a remembrance for the generations, as it says "This shall be to you a law for all time: to make atonement for the Israelites for all their sins once a year..." (Vayikra 16:34)