We are in Maseches Avos, chapter 3, mishnah 7 (and in some versions mishnah 6). The author of this teaching is Rabbi Chalafta ben Dosa of Kfar Chananya, the head of the town of Kfar Chananya - a place situated just south of Meron in the north. This mishnah echoes the idea we saw in mishnah 2: the resting of the Shechinah, the presence of the Holy One, Blessed is He, with a person while he is engaged in Torah.
It is worth noting that the Bartenura's version of this mishnah speaks of people sitting in judgment - judges who convene to decide a case before them. We will set that reading aside for now and follow the text as we have it: people sitting and learning Torah.
"Asarah sheyoshvin ve'oskin baTorah":
Ten people who sit and learn Torah - "Shechinah shruyah beineihem, shene'emar: Elokim nitzav ba'adas Kel" - the Shechinah rests among them, as it says: "God stands in the congregation of God." The context of the source verse in Tehillim (chapter 82) does indeed deal with the judicial system and the courts, but the opening idea is that the Holy One, Blessed is He, stands in the congregation of God.
The word 'edah' means a community, and it refers to a group of ten. This principle is derived from the wording of the verse: "Ad masai la'edah hara'ah hazos?" - "How long shall this evil congregation continue?" The congregation there refers to the spies who scouted out the Land of Israel, and of them only ten were wicked, since two of them were good. From here we learn the law of what constitutes an 'edah'.
In general, 'edah' means a group that gathers together for a particular purpose, from the root 'ya'ad' (to designate), and also related to 'edus' - witnesses who testify. Unlike a 'tzibbur' or a 'kehillah', an edah convenes around a unifying, defined purpose. So it is with a minyan: ten who gather in order to pray together - that is an edah. And so too when people gather with the aim of learning Torah - they are an edah, and the Holy One, Blessed is He, comes and stands with them.
"Umnayin afilu chamishah":
From where do we know that even five who gather and learn Torah together have the Shechinah resting among them? "Shene'emar: va'agudaso al eretz yesadah" - as it says: "and He has founded His band upon the earth." 'Agudah' means a group or a company, and in its plain sense - something that can be grasped in the hand, like a single bundle of lulav and esrog. And the hand itself has five fingers that grasp together, and from here we see that an agudah is a group of five. Even the thumb, the opposing finger that does the grasping, is called 'gudal' - and there may well be an etymological connection here, though it is not entirely clear. The point is that five things coming together to grasp form an agudah, and five is the minimum. That is how the proof verse works here.
And in the context of the verse, which is stated in the prophet Amos: "He builds His upper chambers in the heavens" - the Holy One, Blessed is He, builds His upper chambers in the heavens, "va'agudaso al eretz yesadah" - and as for the people who gather together on the earth in His service and to learn His Torah, He serves as a foundation for them and establishes it for them. The Holy One, Blessed is He, comes there to be with them.
"Umnayin afilu sheloshah":
Even three who sit and learn Torah together, "shene'emar: b'kerev Elokim yishpot" - as it says: "in the midst of judges He judges." 'Elokim' here means judges, and the verse says that the Holy One, Blessed is He, judges in the midst of the judges. This is the second half of the very same verse cited earlier regarding ten: Tehillim 82, verse 1, opens with "Elokim nitzav ba'adas Kel" and continues "b'kerev Elokim yishpot." Since the context of the chapter deals with judges, the 'Elokim' in the verse refers to them. It emerges that the Holy One, Blessed is He, comes there when three sit together. True, the discussion here is about judgment, a Torah court case, but they are engaged in Torah - and it is one and the same.
And indeed, the Tosfos Yom Tov points out throughout the mishnah that the Tanna is speaking of ten judges, five judges and three judges convening together. And if this is so with judges, then all the more so when we are dealing with people learning Torah, the Holy One, Blessed is He, will be present with them.
"U'minayin afilu shnayim" - And from where do we know that this is so even for two?
From where do we know that when two people sit and learn Torah together the Shechinah is with them? "Shene'emar: Az nidberu yirei Hashem ish el re'eihu, vayakshev Hashem vayishma" - as it says: "Then those who fear Hashem spoke with one another, and Hashem listened and heard." This is the very same verse that served us above in mishnah 2. Those who fear Hashem speak with one another - the two friends - and "ish el re'eihu" means two. "Vayakshev Hashem vayishma" - the Holy One, blessed is He, turns His attention and listens. He comes to listen and to be part of the discussion of two God-fearing people who are engaged in Torah, as was explained earlier.
"U'minayin afilu echad" - And from where do we know that this is so even for one?
Here the Bartenura takes a different approach. According to him, the verse quoted above is the one that belongs to mishnah 2, while our mishnah brings a different verse: "Bechol hamakom asher azkir es shemi avo eilecha uveirachticha" - "In every place where I cause My name to be mentioned, I will come to you and bless you." Wherever I cause My name to be mentioned - a person sits and learns, and the Holy One, blessed is He, gives strength to his mind and to his mouth to learn His Torah and to mention His name - "avo eilecha uveirachticha", I will come to that learner and bless him. So the Holy One, blessed is He, comes even to a single individual.
From here an obvious question arises: if the Holy One, blessed is He, comes even for one person, what need is there for all the other levels? The answer is that although He does come even for an individual, as more people are added at these key points - one, two, three, five, ten - the resting of the Shechinah is revealed with ever greater intensity. And this is hinted at in the language of the verses themselves:
One: "Avo eilecha uveirachticha" - I will come to you and bless you: the Holy One, blessed is He, comes, as it were, for a moment.
Two: "Vayakshev Hashem vayishma" - Hashem listened and heard: the Holy One, blessed is He, turns His attention and listens, for a longer period of time.
Three: "Bekerev Elokim yishpot" - in the midst of judges He judges: now He is like one who sits among them, and for a more extended time.
Five: "Va'agudaso al eretz yesadah" - and He has founded His group upon the earth: He is like one laying a foundation, a more permanent connection.
Ten: "Elokim nitzav ba'adas Kel" - God stands in the assembly of God: He stands firmly in place; with ten there is already a permanent structure.
It emerges that the more people learn together, the more powerful and the more lasting is the revelation of the Shechinah.
From here emerges a basic halachic principle, that the Shechinah is found in its place: if there is a beis midrash in your city, you should learn in the beis midrash - not by yourself in the shul, but together with everyone. For in a group there is "b'rov am hadras melech", in a multitude of people is the glory of the King, and Hashem's presence is felt more strongly. This is good for the person, good for the community, and good for all those who are learning; the Holy One, blessed is He, is more connected to a group and to a place where people learn together than to an individual learning on his own.