Torah, Deuteronomy 24:12 – 24:13: And if he is a poor man, you shall not lie down [to sleep] with his security. You shall return the security to him by sunset, so that he may lie down [to sleep] in his garment…
The rich and poor are two Partzufim, upper and lower. Fulfillment of the poor (lower) depends on the rich (upper) that is obliged to give everything to the lower for the fulfillment of the soul. This means “to return a deposit.”
If the upper has a screen that he must transfer to the lower, he doesn’t have a right to delay it, especially at night, because otherwise the lower will find himself in the dark without the means to cope with the darkness, that is, in an egoistic desire. The upper must take care of him, because he has the screen that he can transfer to the lower. This screen is called a garment.
It is written, “You shall return the security to him by sunset, so that he may lie down to sleep in his garment,” in other words, so that he would have protection from egoism.
From the material point of view, it can be interpreted as if a person must sleep dressed in clothes. Indeed, even according to the Torah you must change for the night in some kind of shelter, for example, under the blanket, because like roots and branches, without clothes you become naked.
From the spiritual point of view, “naked” is an inner state when you lose the garment and the Inner Light and the soul disappears from you immediately. You become food for Klipot (impure desires). All your desires immediately turn into egoistic ones.
Therefore, you can undress only in order to enter the Mikva (a pool for ablution) to clean yourself from egoistic desires and to dress again, meaning to obtain the anti-egoistic screen again, because the body is egoism and the garment on it is the screen.
From KabTV’s “Secrets of the Eternal Book” 10/31/16