The writer is merely saying that everything has it purpose in the scheme of things. While it is not clear if the writer believed this was the chronological order in which things appeared, the reason for writing so has to do with the belief that the exile to Babylon occurred because the Jews failed to observe the Sabbath, the cornerstone of the Mosaic Law.
The first chapter of Genesis appears to be the newest and last part of the book written. The language is Sabbath-centric, revealing that the writer(s) were emphasizing adherence to the Mosaic Law by seeing humankind as designed to obey Torah. This is seen in how the writer makes the Sabbath the pinnacle of the story, after the creation of humankind.
With this in mind the narrative plays out as an empty tableau, with parts and pieces placed on it like the backdrop for a play, and then the players put into the place. As such it has two parts:
A three piece tableau is filled: On the first three days the tableau is filled with the settings of night and day, heaven and sea, earth and vegetation. The tableau is now filled, now time to fill the settings.
The settings are filled: On the last three days (before the Sabbath) the settings get filled: the heavens (which is described as a solid dome or firmament) is affixed with luminaries, birds fly over its face and fill the sky, marine life fills the seas, the land is filled with vegetation, animal life, and then humans. And then the Sabbath caps it all off.
First off, the settings are based on the science of the day, the Mesopotamian understanding that the cosmos is filled with water (no vacuum of space was understood by the ancients). These cosmic waters were held back by a solid dome upon which were affixed the sun, moon, and stars. Precipitation came down through windows or gates in the dome. The earth was a flat surface with basins for seas, and all this sat upon a set of pillars which kept it upright in the cosmic ocean, the waters around the pillars being referred to as the “abyss.”
This cosmology is not from the Hebrews, however. The author is only using it as the tableau to fill it with a Jewish meaning, namely that all things are created to fulfill God’s purpose (and subsequently man to fulfill God’s Law).
The luminaries which appear on the fourth day are merely filling their place in the tableau setting. God made the dome or firmament, the writer says. Why? To hold back the waters over the earth, and to provide a place to affix the sun, moon, and stars. The Mesopotamians believed the luminaries were small lights affixed to the firmament/dome which rotated around the earth to created the differences in day and night.
Apart from this the author is unconcerned with whether the Mesopotamian cosmology is sound or not, or has any care about the luminaires themselves. The idea the Jews had after the exile was that God had punished them for not keeping the Mosaic Law. This was foremost illustrated on how little importance Sabbath-keeping held in pre-exile days. Upon returning from Babylon and rebuilding the Temple, the Jews set into place the foundations of the religious system that would become Judaism, with strict rules to prevent the exile from happening again. As such the Torah was recopied with interpolations that included some hermeneutic material, and thus the expansion of the creation story. It originally began with Genesis chapter 2 as the first in a series of creation stories (the Noachian flood is also a creation story). With the return from the exile, this third Sabbath-centric one was added as the beginning or prologue to the rest of the Genesis, which in reality is the prologue to the entire Mosaic Law.