All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Performing the prayer while wearing shoes is permissible if they are pure (not stained by an impurity). The basis of this ruling is the Hadeeth narrated by Sa'eed Ibn Zayd who said: "I asked Anas : "Did the Prophet use to offer prayers with his shoes on?" He said: "Yes.”
There is also the Hadeeth narrated by Shaddad Ibn Aws that the Prophet said: "Act differently from the Jews who do not pray in their leather socks or their shoes." [Abu Daawood] There is no difference in this ruling on whether the prayers are performed in a mosque, a house, or outside, or in the desert, for the general meaning of the Hadeeth. Some Ahadeeth even prove that performing prayers in mosques with shoes on is permitted as reported by Imaam Ahmad and Abu Daawood and narrated by Abu Sa'eed Al-Khudri who said: "The Prophet said: "If one of you comes to the mosque, he should look and if he sees some dirt in his shoes, he should wipe it out and pray in them.”
Moreover, Abu Hurayrah narrated that the Prophet said: "If one of you performs the prayer and takes off his shoes, he should not cause harm (discomfort) with them to anyone (beside him). Rather, he should keep them between his feet or offer the prayer while wearing them." [Abu Daawood]
Besides, Abu Sa'eed Al-Khudri narrated: "While the Prophet, Sallallaahu 'alayhi wa sallam, was leading the Companions in prayer, he took off his shoes and the people behind him did likewise. When he, Sallallaahu 'alayhi wa sallam, finished the prayer, he asked them: “Why did you take off your shoes?” They replied: “We saw you taking off yours.” He said: “Gabriel came to me and informed me that there was some impurity on them.”
However, nowadays mosques are not as they were in the past. Now they are furnished with fine and nice carpets and rugs, therefore, the scholars said: "A person who enters the mosque should take off his shoes to keep the carpets and rugs clean and to avoid causing any discomfort to others with the dirt that may be on the shoes, even if this dirt is not an impurity.
Allaah Knows best.