So the Lord said to Moses, “Take Joshua the son of Nun, a man in whom is the Spirit, and lay your hand on him.
Make him stand before Eleazar the priest and all the congregation, and you shall commission him in their sight."
This is how leadership first transitioned in ancient Israel. Israel at the time was a people in the wilderness, but soon they would cross over into Canaan to take possession of the land God promised to them. And Moses will not be their leader when the new generations took the Promised Land. Now Joshua shall lead.
God made it clear that the people need to see and experience the smooth changeover. Moses would commission Joshua as his successor. The priest would bless Joshua as God's appointed leader. The congregation would witness and affirm the new leader.
Moses was a leader to the end. His last recorded prayer was for God to appoint a new shepherd for Israel (see Numbers 27:15-17). His last official act before hiking up the mountain to view the land and die was to appoint Joshua as Israel's leader. This changing of the guard was necessary, good, and brought glory to God.