Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
Generally speaking, praying while wearing shoes is permissible. However, it is better not to pray in the mosque wearing shoes nowadays, except for one who cannot take them off. In this case, one may pray in them after making sure that they are clean and that he will not annoy those who are next to him.
Answering your question, Dar Al-Ifta Al-Misriyyah, states:
It is important for Muslims worldwide to know that fatwas change according to different times, places, people and circumstances. This means that rulings which have been appropriate under certain circumstances, times and conditions, can never be applied to other contexts of different scenarios.
As for the issue in question, generally speaking, praying while wearing shoes is permitted. The Prophet (peace be upon him) and his Companions used to pray while they were wearing their shoes due to the nature of mosques back then.
Praying while wearing shoes inside the mosque was acceptable at that time because the floors were nothing but sand and pebbles, which may harm whoever pray barefooted.
In this context, the Prophet commanded his Companions to examine their shoes before entering the mosque least they have some dirt on them.
It was reported while the Prophet (peace be upon him) was leading the Companions in prayer, he took off his shoes and placed them to his left. When the people saw that, they followed suit. When the Messenger of God ended the prayer, he asked, “What made you take off your shoes?” They replied, “We saw you took off your shoes, so we followed suit.” The Messenger said: “Jibreel (peace be upon him) came and told me that there was some dirt on my shoes.” And he said: “When one of you comes to the mosque, let him check his shoes, and if he sees any dirt on them, let him wipe it out and pray in them.”
Based on the above Prophetic tradition, praying while wearing shoes inside the mosque is allowed in and of itself based on the following conditions:
1- They must be boots, i.e. they cover anklebones, otherwise, one have to take them off before prayer. So, it is not allowed to pray while wearing flat shoes, slippers, Sandals etc.
2- A Muslim must put them in a state of complete purity. Meaning, one performs ablution, puts on his socks, if any, then wears his shoes.
3- There should be no intervals in which one takes off his shoes during the day.
In this case, it is important to mention the rulings pertaining to the permission of wiping over socks. This necessitates certain conditions too:
1- They have to be thick.
2- They should hold on the feet and cover the anklebones.
3- One should be able to walk in them without being hurt.
4- A person has to wear them over his/her feet while in a state of purity.
This means, one cannot simply wear socks and then wipe over them. You should instead take a regular ablution (including washing the feet), then wear the socks.
Nowadays, mosques are furnished with carpets and entering them with shoes may lead to introducing dirt into the them. If every Muslim was allowed to pray in the mosque wearing their shoes, we would need dozens of workers to clean the mosque after every prayer, not just every day. We do not think that anyone who accepts this would like to pray on a carpet that is full of dust and dirt, let alone other unclean and impure substances, if people are negligent.
Based on this, it is better not to pray in the mosque wearing shoes nowadays, except for one for whom it is difficult to take off his shoes. In this case, one may pray in them after making sure that they are clean and that he will not annoy those who are next to him provided he met the above conditions.
However, If this will lead to some kind of argument and resentment, or will put others off, then it is better for him to take his shoes off, in the interests of harmony among Muslims and not causing enmity and hatred.
The Muslim can observe the Sunnah and obey the Prophet (peace be upon him) by praying while wearing his shoes when that will not lead to any trouble, such as when praying in his house, street, praying on uncarpeted ground and so on.
Almighty Allah knows best.
Source: www.dar-alifta.org