Allah jalla wa ‘alā says:
يَا بَنِي آدَمَ خُذُواْ زِينَتَكُمْ عِندَ كُلِّ مَسْجِدٍ
“Children of Adam, beautify yourself in your place of worship.” (7:31)
This is part of the 31st verse of Sūrat’l-A‘rāf, and in it there have been mentioned three words which are “names” that are meant to be general, each “name” being able to be split into different types. These names are Banī Ādam, zīnatakum and kulli Masjid, represented in the translation above as “Children of Adam”, “beautify yourself” and “place of worship”.
“Children of Adam” includes both Muslim and non-Muslim men and women. Some of the scholars of the Salaf mentioned that this verse was actually revealed concerning the non-Muslims and their circumambulating the Ka‘bah naked in al-Masjid al-Ḥarām. And so Allah was commanding them to cover their ‘awrah or those parts of the body that are impermissible to be displayed to others.
Based on this understanding, if today some non-Muslims were to enter Masjids for the intention of visiting it, or tourism purposes etc, then they must cover their private parts and also ensure to wear something modest.
“Beautify yourself” is more general than covering the ‘awrah, and is also more general than just clothes. To cover the ‘awrah falls under the category of those things which are essential in life (al-Ḍarūrāt), whereas covering the rest of the body comes under the category of those things which are needed in life (al-Ḥājiyāt), and then beautifying yourself (zīna) comes under the category of those things which complete and perfect life and the religion (al-Taḥsīniyāt).
The generality of the concept of zīna is so broad and encompassing of all the above, that it also includes beautifying, grooming, perfuming, applying koḥl, oral hygiene and wearing the very best of cloth and clothes etc.
Therefore, if the people beautify themselves when they visit one another’s houses, or they receive guests who are of high status, then “indeed Allah is more deserving to be beautified for” as narrated by al-Ṭabarāni on the authority of the Prophet (ṣallallāhu ‘alayhi wa sallam) or from ‘Umar (raḍyAllāhu ‘anhu) as some said.
Some of the Salaf used to reserve their most beautiful and expensive clothes and only use them in prayer. Thus, it is not right for someone to pray in battered or dirty clothes, when they beautify themselves for certain individuals of the creation.
“Place of worship” not only includes every Masjid, but also includes every action that a Masjid is built for such as Ṭawāf (circumambulating the Ka‘bah), I‘tikāf (seclusion in the Mosque), Ṣalāh (ritual prayer), reciting the Qur’ān, Dhikr (making remembrance of Allah) etc. The ruling is general, referring to both the place and the intended act of worship as well.
If we take the general Islamic meaning of “Masjid” then we know that the whole Earth is a Masjid; and with the verse commanding us to beautify ourselves for every prayer, that would even then apply to a man who is praying by himself in the night.
The verse also indicates that it is obligatory for a woman to cover her head in prayer even if she is praying by herself and even if she is allowed to uncover her head in front of her maḥrams who might be present.
Finally, the psychological effect of looking your best for the most important moment in your day – when you converse with Allah – should not be underestimated. Dressing up and beautification brings about confidence and happiness which should all be channelled into a positive and spiritual experience that is worthy of the prayer. Thus by obligating us to physically prepare well for the prayer, we are actually being helped perform that prayer spiritually properly as well, and that is from the mercy of our Lord.
And Allah knows best.