An LDR behaves like an ordinary resistor whose value depends on how much light hits it — typically a few hundred ohms in bright light, rising to hundreds of kilohms in darkness. Pair it with RV1 in a potential divider and the voltage at their midpoint tracks the light level directly: high in daylight, low in the dark, or the reverse depending on which one sits on top.
Here the LDR sits on top, so darkness is what lets that midpoint voltage rise. Once it's high enough to forward-bias Q1's base-emitter junction, the transistor turns on and pulls current through the relay coil, closing the switch that feeds the lamp.
The relay exists because the lamp draws far more current, and often runs on a different voltage entirely, than the low-power sensing circuit could ever supply directly. The transistor switches a few milliamps into the coil; the coil's contacts switch the lamp.
Two components most people skip
RV1 isn't optional trim — it's the only thing setting the threshold. Without it, the circuit only responds correctly to whatever light level the LDR happens to be calibrated for.
D1 isn't protecting the lamp, it's protecting Q1. A relay coil is an inductor, and switching it off makes it briefly fight back with a reverse voltage spike — the diode gives that spike somewhere to go besides through the transistor.
Swap the LDR and RV1's positions in the divider and the whole circuit inverts: lamp on in daylight, off at night. It's a one-wire change either way.