I
"How good are your tents, Yaakov, your dwellings, Yisrael" (Bamidbar 24:5). The duality of this most famous passuk is explicated by our classical commentaries in various ways.
Rashi (citing Bava Basra 60a) notes that the openings of our tents do not face each other. The Kli Yakar adds that Balak wanted to curse Am Yisrael with an evil eye (24:1). However, since Am Yisrael were careful not to injure one another by peering into their neighbors' tents, Bilam was unable to do so.
Rashi translates dwellings as encampments, as does Onkelos. Am Yisrael dwelt according to its tribes (24:2), not intermingled (Rashi). Each group of Am Yisrael recognized its place, and did not attack or interfere with the others. Just as each home respected the privacy of neighboring homes, so too, each tribe respected the different paths in serving Hashem of the other tribes.
This connects to Rashi's second interpretation of dwellings, which understands them to refer to the Beis Hamikdash, both built and destroyed. The Netziv (Meishiv Davar, I 44) attributes the destruction of the second Beis Hamikdash to our failure to respect others who had a different path (derech) in serving Hashem. Instead of recognizing legitimate diverse paths with one aim, to serve Hashem, we accused one another of heresy, which even led to bloodshed. Thus Rashi's literal explanation and Onkelos's translation, i.e. camps separate yet respectful of one another, is critical to preserve that which is refereed to by the Midrashic interpretation - the Beis Hamikdash.
II
The Seforno understands tents as batei medrash. They are good not only to those who learn Torah there, but to the entire nation. We survive, as the name Yaakov connotes, until the end (eikev), because we learn Torah.
Dwellings refer to places of tefila, shuls and Batei Mikdash designated for Hashem to dwell there and to accept our prayers. This enables us, as the name Yisrael implies (Bereishis 32:29), to overcome angels and men.
The next two phrases (24:6) compare us to brooks and gardens, and parallel houses of Torah and tefila. "Those who study Torah in tents draw and give to drink of their waters of Torah to the masses. Those who pray are like gardens that do not cease to produce fruit. Our prayers are never ineffective" (Rosh Hashana 17b). This refers to communal prayer, such as the thirteen attributes of mercy which require a minyan. But the good extends to all of Yisrael whose tefillos are answered.
III
The Ohr Hachaim relates transient tents to those who study Torah only at given times, and permanent dwellings to those who learn Torah constantly. He then proceeds to describe four groups of tzaddikim. The first are like rivers, winding their way, like Shmuel Hanavi (Shabbos 56a), spreading Torah, quenching the thirst of those who drink the living waters of Torah. The second group learn, teach, and rule on Torah law from their place, particularly the Beis Hamikdash. They are compared to gardens, available to all those who wish to taste. The fruits can be brought far and wide, as it is written, "from Tziyon Torah will go out." The passuk (24:6) concludes by comparing us to ahalim, spices, planted by Hashem, and cedars by water. Ohr Hachaim reads it as ohalim, tents. This represents the third group of tzaddikim who learn Torah themselves, but lack the ability to influence others, as Yaakov in his youth who learned Torah by himself in a tent (Bereishis 25:27). As they grow, their roots in Torah grow stronger. The final group are supporters of Torah, wealthy people. Like cedars, they are tall and strong in this world. However, they do not produce Torah fruits because they are not scholars. Nevertheless, because they are by water, supporting those who learn Torah which is likened to water (Bava Kamma 82a) they share equally in the reward of those who learn Torah by their support. Thus, all of Yisrael stand on the roots of the holy Torah, even those preoccupied with worldly matters.
IV
Finally, the Netziv (Ha'amek Davar) relates the four descriptions (24:6) to the two tents and the two dwellings, each in plural form in 24:5. The first tent of Yaakov refers to women. They personify the purity of water. Moreover, their chessed grants more immediate aid to the needy (Ta'anis 23b), as rivers flow to where water is needed. Their greatest chessed is helping others to purify themselves by learning Torah (Berachos 17a). The second tent of Yaakov, that of the men, is compared to gardens, which produce many types of fruit. Every man does many mitzvos, but, like in a garden, should specialize in one. The riverside gardens flourish based on a constant water supply. A Jewish man must strengthen himself daily to maintain his level of avodas Hashem.
The first dwelling is compared to spices planted by Hashem. This refers to leaders who gather to do chessed, which is compared to spices, and perform tzorchei tzibbur - communal needs. While these activities are universal, Am Yisrael's spices are planted by Hashem. Our chessed and community are unique, as they are based on Torah activity and principles. The second dwelling is the gathering of Torah scholars, compared to trees. Cedars represent the greatest Torah personalities, captains of the ship which sails on water.
In most siddurim, Ma tovu is the first passuk recited upon entering shul each morning. In this sense, the Seforno's reference to houses of study and prayer is the most accurate. However, by carefully learning and internalizing the lessons of all the classical commentaries, we become better servants of Hashem. And, as Seforno notes, this is good not only for those who enter the shuls and batei medrash, but for all of Am Yisrael.
More divrei Torah, audio and video shiurim from Rabbi Willig