After Balak twice tried to get Vilma to curse Israel, and instead Hashem put words of extraordinary blessings in her mouth, Balak took Balaam to the top where the idol called Peor stood. From there Vilma observed the people of Israel, and saw Israel dwelling according to their tribes, and as a result, "the Spirit of God came upon him.".
What did Balaam see that caused the "spirit of God" to descend upon him? Rashi explains that he saw two things: a) "He saw each tribe living separately and not mingling." b) "He saw that their entrances did not face one another, so that no one could look into another's dwelling." These two things that Balaam saw in the Jewish people led him to exclaim in wonder: "How good are your tents, Jacob, your dwellings, Israel!" When he said, "How good are your tents, Jacob," he intended to express his emotion because "he saw that their gates did not face one another"; and when he said "your dwellings, Israel," he was referring to the fact that "each tribe lived separately and were not mingling.".
These two qualities reflect the great modesty and decorum characteristic of the people of Israel. The first is: "How beautiful are your tents, Jacob"—that the entrances to residences are not opposite each other to preserve modesty and the privacy of family life.
Superior to this is the quality of "your dwellings, Israel"—that each tribe safeguarded its corresponding lineage. This indicates the rigorous care the Jewish people took regarding matters of ancestry, to the point that they knew with certainty "the records of the lineage and the testimonies that attested to the origin of their births," and therefore lived grouped according to their lineage and not in the jumble of "no man's land." Balaam was so amazed by this behavior that "it arose in his heart not to curse them.""
From this we learn the greatness that lies in modesty and the protection of privacy, to the point that a simple matter, such as the direction of the entrances, ensuring that one is not opposite the other, can cause even the wicked Balaam not to curse the people of Israel, but to bless them with the great blessing of: "as the streams spread out...""
But let no one think that they need to be careful only in serious and fundamental matters of modesty, such as those affecting lineage ("each tribe lived separately and were not mixed"), but that there is no need to be meticulous and observant in a minor detail. It should be understood that this detail, too, is vital and fundamental, to the point that it can be the factor that transforms all negativity into the most perfect blessing.
But there is still room for instinct to try to seduce, since what was said before about extreme care in modesty is only in relation to permanent conduct, but if it is a passing and momentary act, it is not obligatory to be meticulous in every detail of the laws of modesty ("tzniut"). On this point, too, we have here the clear indication that even when the children of Israel are in "your tents," in a temporary residence (such as summer resorts...1), it is vital to be careful in every detail of the laws of modesty.
And when one observes these laws as the Torah commands, the Most High transforms all negative themes into the most sublime blessing, which also includes "your dwellings" - that Hashem will return to us His Dwelling, the Beit Hamikdash, which is to descend and be revealed here in this world, and the Most High will dwell in it until eternity.
(Likutei Sichot, volume 13, Page 78)
1-This is also the place to emphasize a current issue: those who are more "lax" regarding certain matters of modesty and decency during vacations, especially when they are away from the city. Among them are those who say, "I will sin and return" when I get back to the city. This also affects the behavior and clothing of men, but especially of women, who are of singular importance, since the woman is "the foundation of the home." There is much more to say on this topic, but this is not the place.