"ותלמוד תורה כנגד כולם" - The Greatest Mitzvah of All (88)
Torah Study vs. Mitzvah Obligations: Attending a Levaya. The Gemara (1) states: "מבטלין תורה להוצאת המת" - we are supposed to stop Torah learning in order to escort (to burial) a dead person. Even though one does not stop learning in order to do a mitzvah that can be done by others, in this case, it is considered a mitzvah that cannot be performed by others. The reason is because each additional person that attends a funeral and escorts the body to its final resting place adds honor to the niftar (2).
The Obligation. According to the Beis Shmuel (3) and the Shach (4) even if one does not see the gathering or funeral procession, but just hears that it will take place in his city, he is obligated to stop his learning and participate. However, the Netziv (5) and Shu”t Sheilas Dovid (6) show that some earlier opinions argue and hold that the only obligation is if one actually sees the procession. This means that the Gemara is talking about one who is walking to the Beis Medrash to learn, or somehow notices the nearby procession in the middle of his learning. Otherwise, one does not even have to interrupt his work and certainly not his learning. The prevalent minhag seems to be like the lenient opinion (7) because we do not find that people are required to find out about all the funerals taking place in their city in order to participate.
Social Obligation. The Yerushalmi (8) as explained by the Ramban in Toras Ha’adam states that if one has a neighbor who passes away, it is “Derech Eretz” to do the proper chessed and attend his funeral even if one just hears about it, and it means stopping his learning. From this we can discern the proper conduct of participating in a levaya whenever one is connected to the niftar through shul, school, work, relatives, or in any other way. This is the basis for why most people attend levayos.
Participation. Even though the Gemara (9) has differing amounts of participating people for different people - each according to the Torah wisdom of the niftar - the RM’A rules that the average Jew (in his day) has enough Torah knowledge to deserve a large levaya, as large as possible. The Ahavas Chesed (10) assumes that this is still true in his days and it probably applies today as well.
How Far? The Poskim do not discuss the guidelines for attending Hespedim (eulogies) of a niftar and it depends on the level of social obligation, as mentioned earlier. They do, however, discuss the procession. Shevet M’Yehuda (11) and Ahavas Chesed (12) hold that the obligation is to escort the niftar all the way to the burial and wait there till it’s over. Others (13) hold that it is sufficient to escort him/her four Amos (approx. 7 feet) or a bit further. This seems to be the common custom and many who do this are careful not to turn their back until they lose sight of the coffin. There is a basis for this minhag in Leket Yosher (14).
(1) כתובות יז. (2) דברי סופרים יו"ד שסא:א (3) אבן העזר סה:ג (4) יו"ד שסא:ה (5) העמק שאלה יד:ב (6) דבריו על יו"ד שסא (7) בדי השלחן שסא:ד (8) פסחים ג:ז (9) כתובות יז. (01) ג:ה (11) יו"ד שמג (21) שם (31) הובא בדברי סופרים (41) עמ' פח'