(Numbers 27:12:) (And the LORD spoke) [And the LORD said] unto Moses [saying]: "Go up onto this Mount Abarim," and so forth. What reason was there for this to be written after the section on inheritances? It was only that, when Moses heard from the mouth of the Holy One, blessed be He (in Numbers 27:7), "You shall surely give them," he supposed that the Holy One, blessed be He, had been reconciled to him. He said: "Behold, I am giving Israel its inheritance." The Holy One, blessed be He, said to him: "My decree stands in its place. 'Go up onto Mount Abarim,' and so forth — you are no finer than your brother."
Why God's Decree Against Moses Followed the Law of Inheritance
Midrash Tanchuma Buber, Pinchas 10:4
(וידבר) [ויאמר] ה' אל משה [לאמר] עלה אל הר העברים הזה וגו' (שם שם יב). מה ראה ליכתב אחר פרשת נחלות, אלא ששמע משה מפי הקב"ה נתון תתן להם, סבור שנתרצה לו הקב"ה, אמר הרי אני מנחיל את ישראל, א"ל הקב"ה גזירתי במקומה עומדת. עלה אל הר העברים וגו', אין אתה יפה מאחיך.