Japanese people do not wear shoes while sleeping. The premise is a misconception.
Possible confusion with: (a) historical samurai sleeping armored/armed; (b) hospital/elder-care settings where non-slip socks or "room shoes" are used for fall prevention; (c) anime/manga exaggeration. Culturally, bringing outdoor dirt to bedding violates hygiene norms (kegare/kegare avoidance).