The pasuk in Parshas Chukas says, “And Hashem said to Moshe and to Aharon on Hor Hahor, on the boundary of the Land of Edom, saying: Let Aharon be gathered to his nation for he will not come into the land that I have given to the Children of Israel…” (Bamidbar 20:23-24) The time for the death of Aharon has arrived. The Gemara (Rosh Hashana 11a) says, “Hashem sits and completes the lives of the righteous from day to day.” This means that a tzadik only dies when his time is up. He is allotted X number of years to his life, and when that time is up, he leaves this world. However, because he is a tzadik, the Ribono shel Olam doesn’t take him away early. He lives his life to the full extent of the time he was granted at birth.
The Sefas Emes asks that the previously quoted pasuk seems to contradict the principle of a Gemara in Rosh Hashana. The pasuk implies that Aharon is not dying here because “his days are full and his time is up” but rather because he does not have permission to enter Eretz Yisrael with Bnei Yisrael (because of his involvement in the incident at Mei Merivah).
To answer this question, the Sefas Emes makes a beautiful observation: When it says that tzadikim live their full lives,” it does not mean in terms of days and years. It means in terms of purpose. Every person is put here on this world to fulfill a mission. When that mission is fulfilled, then the person leaves this world. With a tzadik, until he fulfills the mission that the Ribono shel Olam had in mind for him when He put his neshama on this earth, the tzadik won’t die.
The Sefas Emes elaborates: Had Aharon been allowed to enter Eretz Yisrael, there would have been more mission for him to accomplish. He would have done the avodah; he would have served as the Kohen Gadol; he would have been in charge of the avodahin the Mishkan. He would have what to do. But because of the aveira of Mei Merivah, he couldn’t go into the land and consequently, his mission had ended, so he had to die.
