Maintaining Distance During Prayer
It is forbidden to sit within four amot (about six feet) of someone praying; whether in front or at either side (or behind), one must distance himself four amot. (Shulchan Aruch Orach Chaim 102:1)
According to the Tur the reason for the above ruling is that when one sits idly near someone praying it appears as though he does not want to accept the yoke of Heaven like the one praying. The Taz rejects this reason explaining instead that since the place where one prays is holy, a person who is within four amot must therefore stand unless he is involved in a “davar shebekedusha” (a matter of holiness), such as prayer or Torah study. Support for this explanation is found in the Zohar, Chayei Sarah (Nahar Shalom).
If one is also involved in his prayers, even if he is saying Mishna Zevachim chapter Eizehu Mekoman, instituted to be said as part of Shacharit, he does not have to distance himself four amot in order to sit down. Some even permit one who is learning Torah as well to sit within four amot, even though it is not part of the prayers (Shulchan Aruch Orach Chaim 102:1)
The later Rabbis explain that ideally it is better not to sit and learn Torah within four amot of someone who is praying unless there is a pressing need, such as someone who is too weak to stand (Mishnah Berurah). The Kaf HaChaim explains that this is also the opinion of the Shulchan Aruch. The principle of legal clarification he applies is as follows: Whenever the Shulchan Aruch first brings an anonymous opinion to be strict, followed by a sole opinion to be lenient — the rule is to be lenient only in a pressing situation.
There is a stricter opinion explaining that the requirement to maintain a distance of four amot applies only to sitting on either side (or behind) someone praying. One is, however, not allowed to sit in front of someone praying as far as the eye can see. This ruling applies even if saying the Shema. (Shulchan Aruch Orach Chaim 102:1)
The Kaf Hachaim explains that in this case where the Shulchan Aruch first mentioned an anonymous opinion (stated above) to be lenient, followed by a sole opinion to be strict, and the letter of the law is in accordance with the lenient opinion — however ideally one should still try to fulfill the strict opinion. So too, the Mishnah Berurah writes in the name of the latter Rabbis that it is good to follow the stricter opinion.