Targum Onkelos: And the Lord said, There shall be Lights in the expanse of heaven, to distinguish between the day and the night; and they shall be for signs and for times, for the numbering of days and years.
Rashi: Let there be luminaries, etc.: They were created on the first day, and on the fourth day, He commanded them to be suspended in the sky, and likewise, all the creations of heaven and earth were created on the first day, and each one was fixed in its proper place on the day that was decreed upon it. That is why it is written:“with the heavens (אֵת הַשָּׁמַיִם) to include their products,”and with the earth (וְאֵת הָאָרֶץ),” to include its products. — [Gen. Rabbah 1:14]
Let there be luminaries: Heb., יְהִי מְאֹרֹת It [the word, מְאֹרֹת is written without a“vav,” [thus, the word can be מְאֵרֹת meaning curses] because it [the fourth day] is a cursed day when children become ill with croup. This is what we learned (Ta’anith 27b): “on the fourth day [of the week], they [the men of the ma’amad] would fast so that children should not become ill with croup.”
to separate between the day and between the night: (This happened) after the first light was hidden away, but during the seven (another reading: during the three) days of Creation, the primordial light and darkness served together, both by day and by night. — [Medrah Yelammedenu , as quoted in Yalkut Shim’oni] According to the Ramban and early editions of Rashi , it appears that the reading, “during the seven days of Creation,” is the authentic reading. Ramban , however quotes the Genesis Rabbah , which states that the original primordial light served only during the first three days, until the sun and the moon were suspended in the sky. After that, the primordial light was hidden away, as in Rashi to verse 4. Note also that several early manuscripts and printed editions of Rashi read: “but in the seven days of Creation, the primordial light and darkness served, this one by day and this one by night.” This is also the reading of Mizrachi , and it appears more accurate than our reading, because, in fact, the light and the darkness did not serve together, as Rashi explains in verse 4.]
and they shall be for signs: When the luminaries are eclipsed, it is an unfavorable omen for the world, as it is said (Jer. 10:2): “and from the signs of the heaven be not dismayed, etc.” When you perform the will of the Holy One, blessed be He, you need not fear retribution. — [from Succah 29a]
and for appointed seasons: This refers to the future, when the Israelites are destined to be commanded concerning the festivals and they [the festivals] are reckoned from the first phase of the moon. — [from Gen. Rabbah 6:1].
and for days: The sun serves for half a day, and the moon for half of it, so that you have a full day.
and years: At the end of 365 days (other editions: and a 1/4 of a day) they complete their revolution through the twelve constellations of the zodiac, which serve them, and that constitutes a year. (Other editions read: and that is 365 and 1/4 days), and they return and start a second time to revolve on the sphere like their first revolution.
Rambam: God thoughtfully willed that, within the realm of the spheres, crystal bodies should pass from potentiality into existence. Their three-fold purpose shall be to distinguish day from night; to serve as miraculous signs, as the signs of the change of seasons, as the measure of day and night, and as the measure of the cycle of the sun which is 365 days and the cycle of the moon which is 30 days;
Ibn Ezra: God said effortlessly, “Let there be lights in the upper heavens which shall be visible in the sky to divide between the day and the night. Let them also be used to tell time in minutes, hours, days, and years.