And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also. And God set them in the firmament of the heaven to give light upon the earth, And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good. And the evening and the morning were the fourth day.
God created the sun, moon, and stars. Each of the lights have a specific purpose – the sun rules the day and divides light from darkness, while the moon and stars rule the night and prepares the earth for the coming light.