My Loving Husband suggests this: God did Moses a favor by denying him access to the Promised Land.
His thinking is that anticipation is the best part of any situation--the moments before you eat a piece of pie when your mouth waters and you remember all the delicious pie that has gone before, the weeks leading up to a reunion/party/holiday/conversation in which you consider what will happen and how great it will all be, the increasingly pleasurable and painful heart palpitations as you look forward to something. The reality almost always disappoints--the pie isn't as tasty as you remember, the reunion/party/holiday/conversation doesn't go as expected, the thing you anticipated simply doesn't live up to expectations.
Thus, Moses had 40 years of anticipation (also 40 years of complaints from the Israelites, but that's another story) and, though he'd succeeded in getting the team to the Promised Land, it would inevitably disappoint. Instead of committing themselves whole-heartedly to God and resisting falling into old habits, the people would continue to live their flawed, human lives in the Promised Land, they'd pillage and murder, resent and frustrate. Moses gets to live up to the edge of his anticipation, not being let-down by reality.