I remember hearing that you can't sleep with socks. I think Rambam stated this (correct me if i am wrong), but where in Rambam was it said and why do we do it?
מיושב: דאז בהכרח יתגלה גופו והאדם צריך להתנהג בצניעות ובושה לפני הקב"ה ואפילו כשהוא לילה ובחדרי חדרים הלא מלא כל הארץ כבודו וכחשיכה וכאורה לפניו יתברך....ע"כ האנפלאות יראה ללבשם או לפשטם ג"כ תחת הסדין שלא לגלות רגליו שדרכן להיות מכוסות לעולם במדינות אלו שאין הולכין יחף אפילו בקיץ....
That way, a person would reveal his flesh, and a person needs to act modestly wherever he is, even in private, because Hashem is everywhere. Even at night, and in a closed room; for "the world is filled with His glory," (Yeshayahu 6:3) and dark and light are the same to Him....therefore, it would appear that one should put on and take off one's sock under his covers, so that his feet should not be uncovered, for it is the norm in our places to always walk around with our feet covered, even in the summer we never walk barefoot....
( my own translation )
In context, it's clear that the issue with this is because of tzniyus, modest dressing.
[h/t Danno in comments]
The Gemara (Yoma 78b) writes that one who sleeps with shoes on, 'has tasted a taste of death', and since tasting death is probably not a good thing, some poskim write that sleeping with shoes on should be avoided (see Kaf Hahayyim Y.D 116:211, for example). The book Shemiras Haguf Vehanefesh (no. 115) also writes that wearing shoes to sleep causes someone to forget his learning. However, this rule is never quoted by the Rambam (as far as I'm aware)
Perhaps some people believe that socks are like shoes in this regard, though I personally don't see why that would be the case. The Mishna Berurah 128:18 writes that while Kohanim are not allowed to wear shoes while they bless the congregation, they may (and should) do so while wearing socks - so at least in some respects socks and shoes are not equivalent
Additional sources regarding shoes, sandals and slippers (but not socks) include:
- Rav Yosef Haim of Baghdad, in Parashat Pinhas Shana Sheniya, 16
- Rav Haim Kanievsk
There is also a disagreement on the length of sleep required for this to be a problem.