“And Yaakov’s sons carried him (i.e. his coffin) to the Land of Canaan” (B’reishis 50:13), “as he had commanded them” (50:12). Rashi explains what was meant by “as he had commanded them,” based on Midrash Tanchuma (Bamidbar 12); Yaakov had told them how he wanted them to carry his coffin: “three [sons] on the eastern side, and so too (3 per side) for all four directions; the formation for the encampments traveling (in the wilderness after the exodus from Egypt) was established here.” Yosef didn’t carry Yaakov’s coffin, his sons Efrayim and Menashe did, and they were two of the three Tribes on the western side in the wilderness. Levi didn’t carry Yaakov’s coffin either, and his Tribe was in the center of the four encampments, with the Mishkan. Rashi, based on the Midrash, explains why Yosef and Levi didn’t carry their father’s coffin: “Levi should not carry [the coffin] because he will carry the [Holy] Ark, and Yosef should not carry [it] because he is a king.” The Midrash explains it further, with Yaakov telling his sons that Yosef should not carry it because they have to give Yosef honor, as he is a king, and Levi should not carry it because he will carry the Ark of the One-Who-Lives-Forever, so shouldn’t carry the ‘ark’ of a corpse” (the word “aron” is used for both “ark” and “coffin”).
Some ask how Moshe, who was a Levi, could carry Yosef’s coffin during the exodus from Egypt (see Sh’mos 13:19) if Levi couldn’t carry Yaakov’s coffin because his Tribe would carry the Holy Ark. Several of the Ba’alay Tosfos (e.g. Chizkuni, Riva, Moshav Z’kaynim) answer this question by saying that Yosef’s coffin carried itself, thereby eliminating the need for Moshe to actually carry it. I’m not sure why not having to do any heavy lifting made a difference, since the point is having to take care of it, not having to literally “carry” it. Besides, since the Holy Ark didn’t need to be carried either, but “carried its carriers” (Soteh 35a). If not doing the actual carrying made a difference, then Levi shouldn’t have been disqualified from carrying Yaakov’s coffin, since he didn’t really “carry” the Holy Ark. (It would also be a bit odd if Yosef’s coffin carried itself but Yaakov’s didn’t.)
I don’t really understand the question to begin with, as not every member of the Tribe of Levi carried the Holy Ark, only some of those who came from K’has (see Bamidbar 4:15; occasionally it was the Kohanim, see Y’hoshua 3:8-17, who also came from K’has, see Sh’mos 6:18-20). Since they were all descendents of Levi, Levi himself couldn’t carry Yaakov’s coffin. However, that shouldn’t preclude any of Levi’s descendents who didn’t carry the Holy Ark from carrying a coffin. Therefore, since Moshe did not carry the Holy Ark (even if his relatives did), there was no problem with his carrying Yosef’s coffin.
Rav Yitzchok Sorotzkin, sh’lita (Rinas Yitzchok), suggests that Rashi did not mean that carrying the Holy Ark disqualifies someone from being able to carry a coffin. Rather, since (1) the formation of the children of Yaakov when they carried his coffin would be the same as the formation of the encampments in the wilderness, (2) the Tribe of Levi would carry the Holy Ark, and (3) the Holy Ark was in the center, Levi couldn’t be part of the formation that carried Yaakov’s coffin, as his Tribe wouldn’t be in the outer formation in the wilderness. (Rashi’s omitting the “carrying the Ark of the One-Who-Lives-Forever” lends support to this approach.) If it wasn’t carrying the Holy Ark that disqualified Levi from being able to carry Yaakov’s coffin (but his location in the encampments), there’s no reason why Moshe couldn’t carry Yosef’s coffin.
After making this suggestion, Rav Sorotzkin asks why, if the formation carrying Yaakov’s coffin had to match the formation in the wilderness, Rashi had to say that Yosef didn’t carry his father’s coffin because he was king; shouldn’t the reason be because Efrayim and Menashe were part of the formation in the wilderness, and the formations had to match? (He leaves this question unanswered.)
Although Efrayim and Menashe came from Yosef, and had Yosef carried Yaakov’s coffin on the western side it could still be said that the formations somewhat matched, there would have then been only two sons on the western side, not three; if three were needed on each side (as the Midrashim imply), at least one of Yosef’s sons would have had to be there too, which might leave the long-term impression that the other son was not really considered a “son of Yaakov,” and therefore not a full Tribe. If, as Rav Sorotzkin suggests, the formations having to match was enough of a reason to have Efrayim and Menashe carry Yaakov’s coffin instead of Yosef, it could be suggested that Yaakov wanted to avoid making it obvious that he had given Yosef’s sons the status of being full Tribes, as this could re-arouse jealousy among the brothers.
[Bear in mind that making Yosef the firstborn by giving him a double portion through Efrayim and Menashe was still a sore point during Korach’s rebellion hundreds of years later (see Ibn Ezra on Bamidbar 16:1). There is no indication in the text that Yaakov told anyone but Yosef that Efrayim and Menashe would be full Tribes. If anything, the fact that Yaakov never mentioned explicitly in his blessing to Yosef (B’reishis 49:22-46) that Yosef’s sons were given special status indicates that it was purposely not announced publicly. Additionally, if the Tribe of R’eivain could blame Moshe for transferring the first-born status to Yosef (during Korach’s rebellion), it must not have been public knowledge that Yaakov had made Efrayim and Menashe full Tribes before he died. Rather, the transition from being considered Yosef’s sons and Yaakov’s grandsons to being considered Yaakov’s sons, and therefore full Tribes, happened organically, over time, and became fully apparent (and official) shortly after the exodus, when they each had their own path through the split sea, and took their place as two-thirds of the western encampment. It was because it became official under Moshe’s leadership that he could be (wrongly) blamed for transferring the first-born status from R’uvain to Yosef.]
In order to keep his having made Efrayim and Menashe full Tribes under wraps (for the time being), instead of telling his sons that the reason Efrayim and Menashe had to carry his coffin instead of Yosef was because they were full-fledged Tribes, he told them that it was because Yosef was a king, and it was unbecoming of a king to carry the coffin with them. [It should be noted that Midrash Aggada (Bamidbar 2:2), before mentioning who was on the western side, explains why Yosef was not included: “Yosef should not carry (the coffin) because he is king; rather, I have made his sons Tribes, as it says (B’reishis 48:5), ‘Efrayim and Menashe will be to me like R’uvein and Shimon,’ therefore Efrayim and Menashe and Binyamin should carry (the coffin) from the western side.” Obviously, the author of this Midrash, likely a Rishon, had no qualms about Yaakov making it clear that Efrayim and Menashe were full Tribes.]
Interestingly, Rashi reverses the order of the Midrash, mentioning Levi being excluded from carrying Yaakov’s coffin before mentioning that Yosef was excluded, while the Midrash Tanchuma (and its parallel Midrashim, such as Bamidbar Rabbah 2:8) mentions Yosef before Levi. Perhaps Rashi was highlighting the fact that the formations had to match, and Levi not being part of the outer formation in the wilderness was more of a mismatch than Efrayim and Menashe being part of that formation. The Midrash, on the other hand, focused on Levi and Yosef being disqualified from carrying Yaakov’s coffin, so besides giving a fuller explanation of the disqualifications, mentioned Yosef first, thereby giving honor to the king who couldn’t carry his father’s coffin.