In Parshat Pinchas (Bamidbar 27:15-17) we read:
Moshe spoke to the Lord, saying: “Let the Lord, God of the spirit of all flesh, appoint a man over the community who will go out before them and come in before them. Who will lead them out and bring them home. Let not the Lord’s community be like a sheep without a shepherd.”
In verses 18-21, God answers:
“Take Yehoshua Bin Nun, a man infused with My spirit and lay your hands upon him. Have him stand before Elazar the Kohen and before the entire community and command him before their eyes. You shall place some of your majesty upon him, so that the entire community of B’nai Yisrael will obey him…”
The Midrash, Bamidbar Rabba 21:14 asks:
What reason did Moshe have to make this request after declaring the order of the inheritance?
The Midrash answers:
When Moshe saw the daughters of Tzelophchad inherit the properties from their father, Moshe said: “This is the time for me to claim my needs. If daughters inherit, it is surely right that my sons should inherit my glory.”
God answered Moshe with a quote from Mishlei 27:18: “‘He who tends the fig tree will enjoy its fruit.’ Your sons sat with their own concerns and were not involved in torah study whereas Yehoshua served you and showed you great honor. He rose up early in the morning and remained late at night at your House of Assembly. He arranged the benches and spread out the mats. Since he served you with all of his strength, he is worthy to serve Israel and he should not lose his reward.”
Moshe’s dream of one of his sons taking over for him did not become a reality. Yehoshua proved himself in the quiet way that he served Moshe. Since Yehoshua protected Moshe’s honor, he merited to receive Ruach HaKodesh, the Divine Spirit and prophecy.
We can learn from here that leaders should be chosen based on their own merits and not through nepotism.