The Shulchan Aruch (OC 639:02) writes that while one is allowed to eat a snack outside of a Sukka, the halachos of sleeping are stricter, and one shouldn’t even take a short nap outside of a Sukka.
Nonetheless, the Rema justifies the practice of many who don’t sleep in their Sukka.
Firstly, he reasons, the Sukka may be too cold to sleep in. One who is particularly uncomfortable (mitztaer) is exempt from sleeping in a Sukka. The Mordechai (Sukka 741) wrote that in his time (13th Century) most people didn’t sleep in the Sukka due to the cold weather (he lived in Germany).
The Mishna Berura (639:17), however, understands this to refer to someone who doesn’t have pillows and blankets to keep them warm. Seemingly, one who does have would not be exempt from sleeping there. The Levush (Eshel Avraham 640:4), however, writes that even if one does have appropriate bedding though it is quite bothersome to schlepp them in and out of the sukka, then they are exempt from sleeping there (See Nitei Gavriel, Sukkos 59:6).
Additionally, the Rema writes that if one’s wife can’t sleep together with him in the Sukka, he is exempt. The Taz (OC 639:9) writes that as sleeping alone can ruin one’s simchas Yom Tov, it would be better not to sleep in the sukka. The Mishna Berura (639:18 quoting the Biur Hagra) writes, however, that this only applies to a mikva night. On regular nights, one can’t use this excuse, and should either sleep in the sukka alone or ask their wife to join.
The Rema (OC 660:4) cautions against building a sukka that is unfit to live in, due to it not being safe or comfortable, writing that such a sukka wouldn’t be kosher. The Mishna Berura (640:18) points out that if it’s just the climate that makes it difficult, though the sukka is otherwise sound, it is kosher as one could take extra blankets in and sleep there comfortably.
Rabbeinu Manoach (Sukka 6:6) writes that even those who don’t sleep in the sukka at night, should try to do so when napping during the day, especially as many of the above reasons aren’t relevant.Even the Rema writes, however, that it is good to be stringent where possible, and to try one’s utmost to sleep in the sukka.