My speculation is that the image comes from the medieval and earlier times, when night was a dangerous time to be out because wild and vicious predators (4-legged and also 2-legged) prowled the non-urban areas.

It is likely an image that arose long ago, as in "forces of light vs. forces of darkness".