A person who finds himself in a situation in which he has no clothes is obligated to wear at least shorts and an undershirt for prayer (Berachot 25a; Shulchan Aruch 91:1). Although while reciting Shema and berachot it is sufficient, b’dieved, to only cover one’s ervah (Shulchan Aruch 74:6), while praying the Amidah before the King, one must at least cover his ervah and his heart (meaning, his front and back).[6]
All this is b’dieved, but l’chatchilah one should enhance the mitzvah by wearing respectable clothing for prayer, so that one show at least as much honor to God as he does to human beings. Just as a person is careful to wear dignified clothing when meeting important people, so too, he must dress at least as respectably before praying. Indeed, a person who goes out once in his life to greet a king makes sure to wear his nicest clothing. However, a person who sees the king every day does not wear his fanciest garments; but he does make sure to wear clothes that suit his profession and status. Similarly, we come before the King three times a day, and we therefore dress nicely for prayer, but we save our finest apparel for Shabbatot, festivals, and joyous celebrations.
Everything depends on the custom of the place and the person. There are communities where everyone is accustomed to wearing a suit and hat to significant events, and thus they are required to dress that way for prayer as well. Likewise, in a place where it is not accepted to appear before important people in sandals without socks, certainly one must wear socks with his sandals while praying as well. Yet in places where people usually walk around in sandals without socks, and do not wear ties and hats even when approaching important people, they need not adopt different garb for prayer (based on Shulchan Aruch 91:5).
However, praying in a minyan is more important than wearing respectable clothes. Therefore, if someone who usually prays in a suit and hat finds himself in a situation in which going to his house to bring his suit and hat will cause him to miss praying in a minyan, it is better that he pray in simple attire in a minyan, for the mitzvah to pray in a minyan takes precedence over enhancing the mitzvah by wearing nice clothing (Avnei Yashfeh 1:7).
If one is wearing disgraceful clothes, normally not worn on the street, such as dirty work clothes or shorts which he put on to work in his yard, it is better that he change his clothes, even if he will miss praying with a minyan. If he wears such clothing to pray, he will offend the respect of Heaven. Additionally, there is concern that he will not be able to concentrate on his prayer, since he will be thinking that everyone is staring at his disgraceful dress.