“And Moshe spoke to G-d, saying” (Bamidbar 27:15). In a reversal of the usual formula (“and G-d spoke to Moshe, saying”), here Moshe did the “speaking,” even demanding that G-d respond to his request (see Rashi). And it wasn’t just a request that Moshe was making, but a set of instructions (see Sh’mos Rabbah 21:2), telling G-d to appoint a leader to replace him rather than asking Him if he please could (Bamidbar 27:16). Not only that, but Moshe listed a series of requirements for this leader, as if G-d didn’t know what qualifications the leader who replaces him should have! [Although this is not problematic as a request, since we are supposed to speak out every detail of what we want in our prayers to G-d (if for no other reason than to help us better understand what our needs really are), as a set of instructions, it makes it seem as if G-d needed to be told these qualifications so that He wouldn’t appoint a less qualified leader.] What led Moshe to be so forceful with G-d about who should take over, making it seem as if G-d wouldn’t take care of it properly on His own?
Rashi (27:15), quoting the Sifre, praises the righteous because at the time of their death they put their own needs aside and deal with the needs of the public instead. Moshe is included in this praise, because after he was told that he was going to die (27:12-14), the very next thing he did was to ask/tell G-d to appoint an appropriate leader for the nation. However, on the very next verse (27:16), Rashi tells us that the impetus for Moshe’s request/demand was the daughters of Tz’lafchad inheriting their father’s portion, as it reminded Moshe that the time had come to advocate for his own sons to inherit his position. If the reason Moshe made his request was because he wanted his sons to take over, how could Rashi say Moshe put his own needs aside for the needs of the nation?
This question is asked by numerous commentators, with some (e.g. B’er Yitzchok, see also Nachalas Yaakov) suggesting that the main thrust of Moshe’s request was on behalf of the nation, to make sure they had a leader. He also wanted at least one of his sons to be that leader, but since the request was primarily to take care of the nation, it could be said that Moshe put his needs aside on behalf of the nation. This works better with the wording of the first printing of Rashi’s commentary (see Sefer Yoseif Hallel), where the words “put their own needs aside” do not appear (and the praise is only for becoming involved in the needs of the public), but most editions of Rashi, and the Sifre he is quoting, mention putting their own needs aside as well. [As we shall see, these words being in the Sifre may have less significance than usual.] Nevertheless, since the inheritance going to Tz’lafchad’s daughters started the process, it would seem that Moshe advocating for his sons was a primary factor here, leaving the question of how Moshe’s request/demand could be considered on behalf of the nation rather than on his own behalf.
Some (e.g. Sifsay Chachamim) suggest that when Rashi says Moshe put the nation’s needs first, it means that he made sure they had a leader first, before beseeching G-d to let him enter the land (see D’varim 3:23-25). However, he wouldn’t have known they needed a leader until after G-d made it clear that there was no chance he could cross the J ordan, so the demand/request to appoint a leader had to have come after he had already made his personal request (and been denied). As a matter of fact, after he was denied, G-d told him to “ascend to the top of the height (of the mountain)” to see the land, since he will not be able to go there himself (3:27), which is likely a reference to the same “ascension” described here (Bamidbar 27:12-14). [According to this, when it says (there) that Moshe should “command Y’hoshua” (D’varim 3:28),who will be taking over the leadership, it is the same conversation described here (Bamidbar 27:18). It would be very awkward if G-d had already told Moshe that Y’hoshua would take over for him to then ask to be able to continue his role, thereby pushing Y’hoshua aside.] Besides, even if Moshe’s demand/request for a leader took place before his supplication to be able to enter the Land, if the leader he wanted was one of his sons, it would still not really be on the nation’s behalf.
The Sifre continues by saying explicitly that Moshe’s demand/request was for Y’hoshua to be the leader. Theoretically, this could fit with Rashi’s wording on these verses as well, and except for Rashi not saying explicitly that Moshe wanted Y’hoshua to take over, may fit even better. Rambam (Hilchos M’lachim 1:7), after telling us that when a king dies his son becomes the new king, adds: “And not only the monarchy, but all leadership positions and appointees are to be inherited by [the leader’s] son and his son’s son, forever, as long as he can fill his fathers’ position in wisdom and fear (of G-d). If he can fill [his position] in regards to fear (of G-d), even if he does not match his wisdom he takes over his father’s position and is taught (wisdom). And whoever does not have fear of heaven, even if his wisdom is greater (than his father’s) should not be appointed to any position in Israel.” If we can safely assume that Moshe’s sons feared G-d, it would seem that Moshe didn’t have to ask for his sons to take over, as it would have happened anyway. The demand/request makes much more sense if Moshe had assumed that his sons would take over but wasn’t comfortable with it because he thought Y’hoshua would make a much better leader. Let’s see how this fits into Rashi’s words.
After Tz’lafchad’s daughters are given their father’s inheritance, Moshe, who had always focused on the nation’s needs rather than his own or his family’s, realizes that his sons will inherit his position too, even though Y’hoshua is much more qualified. He therefore petitions G-d to appoint someone else (Y’hoshua), someone who has all the characteristics of a leader and is therefore better suited to lead the nation. (This is why Moshe had to list all the characteristics, to highlight why Y’hoshua is a better choice.) He had to be forceful with his request, since he is asking for a change in protocol, and wants to make sure that his request comes across as being what he really wants to happen, despite the personal sacrifice involved. These actions personify him putting his own needs aside on behalf of the nation, while at the same time being the result of his realization (spurred by Tz’lafchad’s daughters) that his sons are supposed to inherit his position. G-d’s response? Don’t worry, I never considered anyone but Y’hoshua, since he deserves it and is the most qualified. The expression Rashi uses, “it never entered My mind,” doesn’t mean “Sorry, but I can’t fulfill your request,” but, as the words themselves indicate, “your concern about who should lead the nation was unnecessary, since I (G-d) had intended for Y’hoshua to be the next leader all along.”
Tz’lafchad’s daughters inheriting their father being the catalyst for Moshe bringing his sons into the equation is based on Midrash Rabbah (21:14) and Tanchuma (11). There, the words “it never entered My mind” do not appear, so Rashi including them in his paraphrase of this Midrash indicates that he was trying to get this thought across, that Moshe had requested/demanded that G-d appoint a leader with the right qualifications because he thought otherwise it would go to his sons, with G-d responding that He never considered doing such a thing. Whether or not Rashi thought this was the intent of the Midrash itself (and Midrash Rabbah saying that Moshe was being forceful because he was asking on behalf of the nation does indicate that the request was on their behalf, not for himself), it certainly seems to be what Rashi is trying to get across to us. [This Midrash does not tell us that Moshe was putting his own needs aside for the needs of the nation, so there is less of an issue if its intent was that Moshe was asking for his sons to take over. And if Rashi was following this line of thinking, his paraphrasing the Sifre without including the words “leaving their needs aside” fits.] It is only because Rashi quotes the Sifre and paraphrases the Tanchuma that reconciling the two becomes necessary.
If we only had to reconcile Rashi’s commentary on these verses, Moshe asking G-d to appoint Y’hoshua instead of his sons (with his realization that his sons would otherwise inherit his position coming because of Tz’lafchad’s daughters) addresses all the issues. However, there is another part of the Tanchuma that Rashi paraphrases, with G-d telling Moshe that by making Y’hoshua “stand before Elazar the Kohain” (27:21) He was fulfilling his request to “keep things in the family.” If this was Moshe’s request, he obviously was not asking for Y’hoshua to be appointed. So not only are we back to square one, but we have another issue to contend with; if Moshe’s request was for his sons to take over the leadership, how would his nephew Elazar being part of the administrative process fulfill that request?
I would therefore suggest that Rashi was using the ideas expressed in both Midrashim to paint a more complete picture. Moshe’s primary focus was always the nation, which had taken its toll on his family life (see Rashi on Bamidbar 12:1). The daughters of Tz’lafchad getting their father’s inheritance reminded him that he also had the responsibility of taking care of his sons’ needs after his death. These dual responsibilities were now at odds, as his role as the nation’s leader meant ensuring that the person succeeding him would be the most qualified candidate, Y’hoshua. At the same time, as a father, he was supposed to advocate on behalf of his sons. In order to navigate these dueling responsibilities, knowing that the “default setting” was his sons inheriting his position, Moshe forcefully asked G-d to appoint the most appropriate candidate, without explicitly mentioning Y’hoshua’s name. He put the nation first, and made his forceful request after the situation with daughters of Tz’lafchad reminded him that his sons would inherit his position if he didn’t do something, but because they were his sons, he didn’t mention Y’hoshua’s name, thereby leaving open the possibility that G-d would give it to them anyway (perhaps by giving them the tools needed to do the job as well as Y’hoshua would). G-d told Moshe that he never considered anyone but Y’hoshua for the position, but since Moshe had worded his request the way he did because of his responsibility to his family, someone from his family would have a leadership role too.