Reading from Deut 8-34
God Even in his sovereignty knew in advance the Israelites were going to rebel and disobey him. He still gave them his law, because of love.
I really felt sadden for Moses in Deut 34 when God said "I will let you se it but you shall not go over there" after all he did for these complaining, stiffnecked people compared to he slipped up by striking the rock for waters of Meribah ( Duet 32:51-52)
Even in this we don't see in the text Moses complaining, instead he continues to faithfully honor God leads the people and gives them last directives and new leader Joshua.
A leader is always held to higher standards.When much is given much is required to obey.