During takeoff, descent and landing, cabin lights are switched off so that in case there are any problems, the crew can look outside through the windows (especially at night when it's difficult to see what's outside with lights on), they can alert the pilots.
For instance, if there is damage to a wing, the pilots can not visually see this but the crew can, and notify them.