The habitable volume of the Apollo lunar module was just 160 cubic feet. That might sound like a lot for two men, but when you consider that it was filled with the bulky lunar EVA suits and life support systems, rocks collected from the surface, and all the other things needed for a lunar stay it wasn’t exactly roomy. Add the noises of the environmental control system and the light streaming in the window and it might be the least restful place for a nap.
Early mission planning showed that the first landing landing flight, which became Apollo 11, would spend about 22 hours on the surface. That meant NASA knew right from the start that astronauts were going to be sleeping on the Moon; it wouldn’t just be a consideration for the later extended missions.
All the same, the LM was built for functionality, not for comfort. The spacecraft was built solely to land on the Moon, and one of the design constraints was that it be as light as possible. Weight was such a premium that bundles of wires weren’t hidden behind panels because the panels would add too much weight. Plumbing was exposed, circuit breakers were uncovered, and the vehicle’s shape worked around things like fuel tanks. The result was that the LM didn’t exactly have luxurious sleeping quarters.