Rabbi Abba bar Avina asks, “Why is the parashah of Miriam’s death written immediately after the parashah of the Red Heifer? To teach that just as the ashes of the Red Heifer atoned for sin, so does the death of the righteous atone.”
Rabbi Chiya bar Abba says, “Aharon’s sons died on the first of Nisan. Why is the parashah of their death mentioned on Yom Kippur? To teach that just as Yom Kippur atones, so too, the death of the righteous atones” (Vayikra Rabbah, Acharei Mot 20:12).
Our Rabbis seem to imply that Hashem is pleased with the death of the tzaddikim, as is learned from the pasuk (Shir Hashirim 6:2), “My beloved went down to His garden… to gather the roses.” The Zohar calls the death of tzaddikim a hilula, a cause for celebration (Alshich, Vayikra 16).
The Zohar states (Parashat Vayechi 248b) that when a tzaddik passes on, there is a certain unity which is attained between the Holy Name of the Shechinah and the Ineffable Name, similar to the joy of a chatan and kallah. It has become common practice to call the death of a tzaddik a hilula (Alshich, Vayikra 25).
Hashem has declared the day of Yom Kippur to be a yearly day of atonement (Vayikra 16:34). Its very essence atones for sin (Yoma 85b). So does the death of the righteous atone for sin. Although down below, the tzaddik’s death is mourned, in the World Above, it is a day of celebration (Zohar III, 291a). Since it is an auspicious day, it also atones for sin (Shelah, Ta’anit, Perek Torah Ohr).
The word hilula means unity (Degel Machaneh Efraim, Vayikra, Parashat Kedoshim).
Regarding the death of Moshe Rabbeinu, the pasuk says (Devarim 32:48) that Hashem told Moshe to ascend Mount Nevo, in order for his neshamah to be taken, “in the middle of that day.” The death of a tzaddik is called a hilula (Mo’ed Katan 25b). Hashem delights in the tzaddik just as one delights in a new kallah. Chazal say that the tzaddik finds rest after his death, and there is an abundance of light which descends upon the world in his merit. Moshe Rabbeinu’s death is described as taking place “in the middle of that day,” for an especially strong light shone then (Rabbi Tzadok Hakohen MiLublin, Pri Tzaddik, Vayikra L’Chag HaPesach).
Rabbi Tzadok Hakohen further writes (Pri Tzaddik, Lag Ba’Omer): Lag Ba’Omer is called the hilula of Rabbi Shimon bar Yochai, for on that day, he ascended to Heaven. We find that the anniversaries of the deaths of certain tzaddikim, such as Moshe Rabbeinu on the seventh of Adar, and Aharon Hakohen on Rosh Chodesh Av, were instituted as days of fasting. Why, then, was the anniversary of the death of Rabbi Shimon bar Yochai made into a day of celebration?
The anniversaries of the deaths of tzaddikim that were specified as fast days are the deaths of those recorded in the Written Torah. Regarding days of the deaths of the Ten Holy Martyrs, fasts were also established on these days, as they were killed and did not die naturally. Moshe Rabbeinu was the root of the Written Torah, whereas Rabbi Akiva was the root of the Oral Torah. The day he passed on, his divrei Torah took root in the hearts of his disciples.
Rabbi Shimon bar Yochai was one of Rabbi Akiva’s foremost disciples. With his death on Lag Ba’Omer, his entire generation was enlightened by his teachings. Therefore, it is called the hilula of Rabbi Shimon bar Yochai. Rabbi Akiva’s day of death could not be a day of rejoicing, for he died a martyr’s death. Instead, a celebration was enacted on the day of Rabbi Shimon bar Yochai’s death. Rabbi Shimon bar Yochai’s neshamah was connected to that of Rabbi Akiva.
We are taught that Moshe Rabbeinu died on the same day that he was born, the seventh of Adar, since Hashem completes the years of the tzaddikim, day for day. From this we can deduce that Rabbi Shimon bar Yochai was born on Lag Ba’Omer, the day of his death (see Kiddushin 38a). Every year, on this day, everyone can attain a portion in the Oral Torah, which came down on this day. Therefore, it was established as a festive day.