Bamidbar24:5

מַה־טֹּבוּ אֹהָלֶיךָ יַעֲקֹב מִשְׁכְּנֹתֶיךָ יִשְׂרָאֵל׃

How good are your tents, Yaakov, your dwellings, Israel!

Bamidbar 24:5

מַה־טֹּבוּ אֹהָלֶיךָ יַעֲקֹב

Bamidbar / Numbers 24:5 · Drash

Bamidbar 24:5

מַה־טֹּבוּ אֹהָלֶיךָ יַעֲקֹב מִשְׁכְּנֹתֶיךָ יִשְׂרָאֵל׃

How good are your tents, Yaakov, your dwellings, Israel!

Drash דְּרָשׁ

A blessing turned around

Sometimes praise reveals what a person really meant to say. The Talmud reads Bilam's blessing and hears beneath it the curse the Eternal turned around.

The Talmud: from the wicked man's blessing one sees what was in his heart. Each blessing of Bilam (Balaam) is a curse the Eternal turned around: Bilam wanted Israel to have no synagogues and houses of study, and he said "how good are your tents". Midrash Lekach Tov: the tents are houses of study, the dwellings are synagogues.

How Talmud, Sanhedrin and Midrash Lekach Tov explain it

Talmud, Sanhedrin How good are your tents, Yaakov

Rabbi Yochanan said: from that wicked man's blessing you learn what was in his heart. He wanted to say that they should have no synagogues and houses of study: "how good are your tents, Yaakov (Jacob)". That the Presence of the Creator (שְׁכִינָה) should not rest on them: "your dwellings, Israel". That their kingdom should not last: "like streams they stretch out". That they should have no olives and vineyards: "like gardens by the river". That their fragrance should not spread: "like aloes that the Eternal has planted".

Talmud, Sanhedrin Like cedars beside the waters

That they should have no tall kings: "like cedars beside the waters". That they should have no king son of a king: "water shall flow from his buckets". That their kingdom should not rule over nations: "and his seed shall be by many waters". That their kingdom should not be strong: "and his king shall be higher than Agag". That their kingdom should inspire no awe: "and his kingdom shall be exalted".

Midrash Lekach Tov How good are your tents, Yaakov

These are the houses of study. "Your dwellings, Israel": these are the synagogues.

Takeaway

Further on the Talmud says that all Bilam's (Balaam's) blessings later turned back into curses, except the synagogues and houses of study: these remained for ever (Sanhedrin 105b).
Agag is the king of Amalek in the days of King Shaul (Saul) (Shmuel I / I Samuel 15:8).
The words "How good are your tents, Yaakov" open the prayer on entering a synagogue.