When a person gets dressed, even when he is alone in his house, it is proper that he act modestly. He should not say, “I am in the privacy of my own room; who can see me?” for Hashem’s greatness fills the whole world. Therefore, it is proper that one who sleeps without clothing be careful not to arise from his bed nude and then get dressed. Instead, he must partially dress under his blanket while still in bed, so that his ervah (nakedness) will remain covered when he rises. Similarly, when one needs to change his underwear, it is proper to do so under a blanket, or while he is wearing a long robe that covers his ervah. He may change his underwear in the bathroom or shower room, for those places are intended for that purpose – undressing there is not an affront to modesty.
It is an extra pious act to be cautious that every part of the body that one respectfully covers when in the company of family and close friends is covered when one is alone as well. Therefore, it is an expression of piety not to be without an undershirt, even when alone in a room. If a person wants to change his undershirt, he demonstrates his piety by doing so only in the bathroom.
When someone suffers greatly from the heat, even in accordance with the extra pious custom, he is permitted to remove his undershirt. However, he may certainly not expose his ervah. Talmidei chachamim (Torah scholars) are generally more stringent. Even on hot days when they are alone in their rooms, they do not remove their undershirts, nor sit in their house shirtless among their close friends or family members.
All the circumstances mentioned above are situations in which there is no real need to expose one’s ervah. However, when there is a necessity, such as for bathing or medical purposes, one is permitted to uncover his ervah (Igrot Moshe, Yoreh De’ah, part 3, 68:4).
In order to slightly clarify the matter of modesty, it is necessary to initially state that in the beginning, when Adam was created, he was pure and clean, both spiritually and physically, and he did not feel a need to wear clothes. However, after the sin, he began to feel ashamed of his nudity. From then on, we all cover our bodies with clothes, especially those parts connected to the sexual drive and the disposal of waste.
The bare body emphasizes in an extreme manner the physical and animalistic side of humans. However, the form of the human body, with all the details and intricacies of its organs, also contains profound and phenomenal allusions to the soul, which the wisdom of the Kabbalah discusses in great length. It is the destiny of the body to reveal and actualize all those spiritual ideas. However, following Adam’s sin, man’s view of the world became more external. At first glance, we see only the corporeal component of the human body, which causes us to forget its spiritual core. Therefore, it is proper to hide the parts of the body that are normally covered, to better emphasize a person’s inner spirituality, which is the source of his beauty, and thus allow this exalted spiritual beauty to extend over his whole body. That is what Chazal infer when they state that it is in fact modesty which preserves beauty, by nourishing its eternal root (see Bamidbar Rabbah 1:3).
From Aruch HaShulchan 2:1, it seems that the essence of this stringency is to make sure one does not expose half of his body, but he explicitly permits revealing one’s legs. If so, one may change his pants without covering himself, if he is wearing underwear. But concerning an undershirt, it is proper to be careful. Rav Mordechai Eliyahu ,ztz”l, similarly notes in his Kitzur Shulchan Aruch 3:1 that whoever is wearing underwear need not get dressed under a blanket. The Mishnah Berurah 2:1 is stringent, based on a number of Acharonim, and states that one may not reveal any parts of the body that are normally covered. Therefore, even one’s socks should be put on under a blanket. However, Igrot Moshe, Yoreh De’ah, part 3, 47:3, and section 68:4, explains this to mean that any part of a person’s body that is considered shameful to expose while sitting in his house with his family or friends should not be revealed when he is alone as well; every place according to its custom. Therefore, nowadays, even according to the Mishnah Berurah it is certainly not necessary to be strict about one’s socks. Furthermore, he writes, the extra pious custom only applies under regular conditions, but one who suffers from heat is permitted to be lenient (and remove his shirt and even his undershirt). This is the law regarding an elderly person who has difficulty changing his undershirt under a blanket, or a woman who is afraid her shirt will get wrinkled. (This is also written in Halachah Berurah 2:1, in the name of his father, Rav Ovadyah Yosef). However, the Igrot Moshe adds that one’s ervah itself should not be revealed at all unless there is a substantial need, such as for bathing and medicinal purposes. Based on this, I have differentiated above regarding the extra pious act, between one’s ervah and the other parts of the body that are normally covered. Concerning an undershirt, I wrote “the extra pious act,” for even though the Shulchan Aruch brings it as halachah, most poskim agree that it is an extra pious act and not an obligation (see Mishnah Berurah 3:18, where it talks about this law). (Moreover, one may say that during the time of Chazal, it was a comfortable solution to put one’s head and hands in his robe while still lying down, and that way, when he rose he was automatically covered, but to put on a tight undershirt under a blanket is harder. This is another reason why it is an extra pious act and not a mandatory custom. Furthermore, today there are places in which people are not embarrassed to sit in front of their friends without an undershirt.) Talmidei chachamim are customarily more meticulous in observing the extra pious custom, and even when it is very hot, they certainly do not walk around their houses shirtless. Many are even strict not to walk around their houses in a sleeveless undershirt.