"G‑d was also angry at me on your account." (Deut. 1:37)

This is difficult as we have no independent evidence of G‑d having become angry at Moses on account of the sin of the spies. I believe the correct meaning of these words must take into account what the Talmud said in connection with the people crying during that night. (Ta'anit 29 on Numbers 14:1) The Talmud says that because of their needless weeping on that might the Jewish people were condemned to weep on that date with good reason for many many years, when they would mourn the destruction of both Temples which occurred on the anniversary of that fateful night.

...they would mourn the destruction of both Temples which occurred on the anniversary of that fateful night.

The Talmud adds that if Moses had been allowed to enter the Holy Land the very first Temple would have been the final Temple, i.e. there never would have occurred a destruction of the Holy Temple. (Sota 9)

In this connection there is an interesting Midrash where Assaf appears to have dedicated a hymn to the destruction of the Temple. (Midrash Tehilim on Psalm 79:1) The Midrash asks, predictably, that instead of dedicating a hymn to such an event Assaf should have written an elegy, a song of mourning! The answer is that Assaf composed the hymn in gratitude to G‑d who had vented His wrath on buildings of wood and stone such as the holy Temple and the city of Jerusalem instead of on human beings.

If we extrapolate on the reasoning of the Midrash and consider the fact that the Temple Moses would have built would have become indestructible, then every time the people sinned G‑d would have had to pour out His wrath at the people themselves instead of at the Temple. In order to avoid such a thing from ever occurring, G‑d decided to let Moses die on the East Bank of the Jordan. This is what Moses meant when he said that G‑d’s anger at him worked in Israel’s favor, i.e. biglalchem, "for your sake."

Had the sin of the spies not occurred, Moses would have entered the Holy Land with the result we have just described. The world biglalchem is derived from galgal, "revolving," or in the metaphysical sense "transmigration (of souls)." When G‑d decreed death on Moses which would result in his ultimate reincarnation, He did the Israelites a great favor by venting His wrath at Moses at that time.

Alternatively, the meaning of the words: "G‑d was also angry at me on your account" may be that Moses implied that ‘if you would not have become guilty of this sin and I would have been allowed to enter the Holy Land and build the Holy Temple, there never would have arisen an occasion for G‑d to become angry at you at all, as you would have retained your level of righteousness permanently.’ Had it not been for this sin, the power of evil would never have become as great. Now that this had happened, G‑d realized that once the Israelites would enter the Holy Land they would not be able to maintain their spiritual high. We can derive all this from a study of the song Moses composed in parashat Ha’azinu.

In that event, G‑d would have cancelled His oath...

You may counter that this may be fine homiletics, but the fact remains that Moses’ death in Transjordan was caused due to his failure to speak to the rock at the waters of Meriva (Numbers, Chapter 20) not to the sin of the spies. The answer which I have mentioned already on that occasion is that had Moses spoken to the rock at that time the Israelites could have recovered the spiritually high level they possessed prior to the sin of the spies by means of watching that great display of G‑d’s power. In that event, G‑d would have cancelled His oath not to let Moses enter the Holy Land seeing that he had become the instrument of sanctifying the name of G‑d on such a scale. As a result, Moses would have entered the Holy Land, would have built the Temple, and the Jewish people would have lived there permanently, trouble free. Israel’s sin at this stage then had prevented all these scenarios from occurring.

[Selected with permission from the five-volume English edition of "Ohr HaChaim: the Torah Commentary of Rabbi Chaim Ben Attar" by Eliyahu Munk.]