What does the Torah mean when it writes "va'Yahafoch Hashem es ha'Kelalah li'Verachah"?
Rashi (in Balak, 24:6): From the Berachos that Bil'am blessed Yisrael we can extrapolate what he had in mind to curse them: 'They should not have Batei Keneisiyos and Batei-Midrashos ... ', 1 only Hashem turned the curses that he wanted to place upon Yisrael into Berachos
Sanhedrin 105b: Similarly, he wanted to curse them that the Shechinah should not rest on them - he said "Mishkenosecha Yisrael"; that their kingdom should not last
In order to break Yisrael's connection with the Shechinah. See Sifsei Chachamim, Balak, Bamidbar 24:6, note 80.
Why does the Torah write "Vayahafoch
Sanhedrin 105b: Because all of Bil'am's Brachos turned into curses, except for one - "Mah Tovu Ohalecha" (only it became an everlasting Berachah). 1
Refer to Bamidbar 24:5:151:1 as to why it was different. Indeed, the Batei Keneisiyos and Batei-Midrashos have been the linchpin of our existence throughout the Galus up to the present day.