When the headlights are turned on, it heats up the hair around it. Once the headlights are turned off, this air cools and condenses on the inside of the lens. This ends up as moisture droplets on the inside of the lens.
If the seal on the headlights is cracked due to dirt, debris or excessive heat, then moisture can seep into the assembly and get into the inside of the lens. Using a replacement seal, or sealing up the headlight with silicone gel will solve this problem.