“One must visit his rabbi on the three pilgrimage festivals” (RH 16b; Sukka 27b). This is so that he can honor his rabbi and learn Torah from him. Doing so allows a person to connect with his rabbi and receive spiritual guidance and inspiration from him. This mitzva shares something with the mitzva to make a pilgrimage to the Temple, as the Sages declare: “Visiting one’s rabbi is comparable to visiting the Shekhina (Divine Presence)” (y. Eruvin 5:1). The holy days when people are off from work are the proper time to do this. Indeed, it is an age-old custom to do so, as we see from the words of the Shunamite woman’s husband. When he saw his wife setting off to see Elisha the Prophet on a weekday, he asked: “Why are you going to him today? It is neither New Moon nor Shabbat” (2 Melakhim 4:23). This implies that on holy days people visited the prophet (the current equivalent of whom would be the rabbi). (See Peninei Halakha: Shabbat 5:15.)
The primary reason for visiting one’s rabbi is to listen to his Torah classes. This tradition dates back to Moshe Rabbeinu. The Sages explain that Moshe instituted that: “They should enquire and discuss matters pertaining to the day – the laws of Pesaḥ on Pesaḥ, the laws of Shavu’ot on Shavu’ot, and the laws of Sukkot on Sukkot” (Megilla 32a). They further stated:
God said to Moshe: “Gather together large groups and publicly teach them…to teach and instruct Israel about what the Torah permits and forbids. Thus My great name will be glorified among My children.” (Yalkut Shimoni, Vayak’hel §408)
People were very careful to attend these sermons, and in this way they fulfilled in an enhanced way the mitzva of visiting their rabbi. However, one who greets his rabbi after services by saying “Ḥag same’aḥ” or “Good Yom Tov” has also fulfilled the mitzva, albeit be-di’avad. Some enhance the mitzva by visiting their rabbis in their homes to hear their words of Torah and moral instruction as well as stories about Torah giants. If many students wish to do this, they should come in groups. This way, they will not burden the rabbi, take away from his personal Torah study time, or detract from his festival simḥa with his family.
The Rishonim explain that the precise parameters of this mitzva depend upon geography. One who lives very close must visit his rabbi every Shabbat. One who lives a little further away should visit him at least once a month. A person who lives a great distance from his rabbi needs to visit him at a minimum on the three festivals, as R. Yitzḥak states (based on Rabbeinu Ḥananel and Ritva; see BHL 301:4 s.v. “le-hakbil”). All this is on condition that he will come home to sleep, because the mitzva of simḥa on the festival must be together with his wife. If, in order to visit his rabbi, he would have to sleep away from home, he is exempt from the mitzva (Sukka 27b). However, there are those who are lenient about this, and others who attempt to find some justification for the leniency. In any case, if it bothers his wife, then even those who are lenient concede that he is forbidden to leave home and make the trip. Furthermore, according to most poskim, even if the wife consents, this custom is unwarranted.
It would seem that this mitzva is rabbinic. This is the approach of Pri Megadim, Pnei Yehoshu’a, and many others. Some have written that it is a biblical obligation (Sho’el U-meshiv; Yehuda Ya’aleh). Perhaps what they mean is that honoring Torah scholars in general is a Torah commandment, and that since the Sages ordained that one should visit his rabbi on the festival, by doing so one he is fulfilling a Torah mandate. (Bikurei Ya’akov 640:22 states something similar to this.) As to the reason for the mitzva, many write that it is in order to learn Torah (Ramban, Shemot 20:7; Responsa Rama Mi-Fano §6; Pri Megadim; R. Charlap elaborates at length in Beit Zevul 3:28). One also fulfills the mitzva of honoring Torah scholars by doing this (Rashi, Ḥagiga 3a; Noda Bi-Yehuda OḤ 2:94). R. Yonatan Eibeshutz suggests that based on the statement that “Visiting one’s rabbi is comparable to visiting the Shekhina” (y. Eruvin 5:1), we can say that since the destruction of the Temple, visiting one’s rabbi takes the place of making a pilgrimage to the Temple (Ya’arot Devash 1:12). See Harḥavot 17:1-4.