Why is a transistor used in a night sensor circuit?
The transistor provides gain.  Basically it's a simple amplifier of the signal produced by the LDR and the pullup resistor.  That signal has rather high impedance, so is generally not useful for driving something else directly, like a LED for example.  Cheap transistors can easily be found that can be counted on to have a current gain of at least 50 in this case.  If you want 5 mA thru a LED as a indicator, for example, then only 100 µA are required into the base of the transistor.
By the way, the 1 kΩ resistor in this schematic serves no useful purpose.