Both Moses and Joshua were commanded to remove their sandals when in a holy place. They were to do this as a gesture of respect or reverence.
فَقَدْ أُمِرَ مُوسَى وَيَشُوعُ كِلَاهُمَا أَنْ يَخْلَعَا نَعْلَيْهِمَا عِنْدَمَا وَطِئَا مَكَانًا مُقَدَّسًا .‏