Al-Aʿrāf: 142
"And We appointed for Moses thirty nights..."
It is narrated that while Moses (peace be upon him) was in Egypt, he promised the Children of Israel that if God destroyed their enemy, he would bring them a Book from God containing the clarification of what they should do and what they should avoid. When Pharaoh perished, Moses asked his Lord for the Book. God commanded him to fast for thirty days—the month of Dhu al-Qa'dah.
When he completed the thirty days, he disliked the odor of his mouth, so he used a siwak (tooth-stick). The angels said: "We used to smell the scent of musk from your mouth, but you have spoiled it with the siwak." It is said that God revealed to him: "Do you not know that the odor of a fasting person's mouth is more pleasant to Me than the scent of musk?" God then commanded him to add ten days from Dhu al-Hijjah for that reason.
It is also said that God commanded him to fast thirty days and to perform deeds during them that would draw him closer to God, and then the Torah was revealed to him during the ten [additional] days, and He spoke to him during them.
The forty [nights] were mentioned summarily in Surat al-Baqarah, and here they are detailed.
"The appointed time of his Lord" is the time He set and designated for him.
"Forty nights" is in the accusative case as a state (hal), meaning: "It was completed, reaching this number."
"Aaron" is an explanatory apposition ('atf bayan) to "his brother." It has also been recited in the nominative case (Harunu) as a vocative.
"Succeed me among my people" means: Be my deputy among them.
"And do right" means: Be a reformer. Or: Reform what must be reformed of the affairs of the Children of Israel, and whoever among them calls you to corruption, do not follow him and do not obey him.
"And when Moses arrived at Our appointed time and his Lord spoke to him, he said: 'My Lord, show me [Yourself] that I may look at You.' [God] said: 'You will not see Me, but look at the mountain; if it remains in its place, then you will see Me.' But when his Lord manifested His glory to the mountain, He made it crumble to dust, and Moses fell unconscious. And when he recovered, he said: 'Exalted are You! I have repented to You, and I am the first of the believers.'"