What was the real reason why the angel commanded Yehoshua to remove his shoes?
(5,15) “And the captain of Hashem’s host said to Yehoshua: Remove your shoe from your foot, for the place upon which you stand is holy. And Yehoshua did so.”
The Midrash brought in the Yalkut Shimoni comments on this posuk that the angel said to Yehoshua that the Torah was only given to those who ate the manna, and so now that the manna had ceased to be given, “remove your shoe from your foot” to mourn for the Torah that has been lost.
Everyone who sees this Midrash is amazed, because the posuk clearly gives a different reason as to why he was required to remove his shoes - because “the place upon which you stand is holy”, and not because of mourning!
But it also is taught in the Yalkut that that day on which the angel revealed himself to Yehoshua was Shabbos, (and this is also clear from the posukim if you examine them closely), and public expressions of mourning are not allowed on Shabbos. If so, how could the angel tell Yehoshua to make a public expression of mourning for the Torah by taking off his shoes?
Because of this problem the posuk mentions a different reason for taking off his shoes - because the place is holy, and people thought that this was the reason why he took off his shoes. Therefore, even though the real reason was because he was mourning for the Torah as the Midrash teaches, it was not considered a public expression of mourning since everyone else did not know that he was doing it for this reason.