"And we abode in the valley over against Beth-peor" (Deuteronomy 3:29). Moses said to them: See how beloved you are before the Omnipresent. To me the Holy One, blessed be He, said that I should not enter the Land, and wrath filled against me like a pregnant woman, for your sake, because I said to you "Hear now, you rebels" (Numbers 20:10). But as for you — "And we abode in the valley over against Beth-peor" — you went astray after the idolatry of Beth-peor, and He did not decree upon you that you should not enter the Land; rather He decreed upon me, that I should teach you statutes and ordinances. For so it is said: "And now, O Israel, hearken unto the statutes and unto the ordinances" (Deuteronomy 4:1).
Moses Barred from the Land While Israel Goes Free at Beth-peor
Midrash Aggadah, Deuteronomy 3:29
ונשב בגיא מול בית פעור. אמר להם משה ראו חיבתכם לפני המקום, לי אמר הקב"ה שלא אכנס לארץ ונתמלא עלי עברה כאשה עוברה למענכם על שאמרתי לכם שמעו נא המורים (במדבר כ' י'), ואתם ונשב בגי מול בית פעור, טעיתם אחר ע"ז בית פעור ולא גזר עליכם שלא תכנסו לארץ, אלא גזר עלי שאלמד אתכם חקים ומשפטים כי כן נאמר ועתה ישראל שמע אל החקים ואל המשפטים (ד א):