Earth in Gen 1:1-2 was not really referring to our earth, it refers to matters that are the substance of the land surface which are shared by all planets including the sun. It is said that Mercury, Venus and Mars contain substances i.e iron and nickel and other heavy elements that can also be found on Earth, even sun is said to have an iron, suggesting that, in the beginning all planets and stars are one- a whole chunk of earth.
In Gen 1:2. This chunk of earth or this collection of dense mass was void or empty, a dense matter that has totally nothing in the surface, shapeless or formless. This is submerged in a seemingly dark liquid form kinda like a nucleoplasm surrounding a nucleus which is a basic building block of matter.
Now, this mass of earth or this so called singularity which is a dense collection of energy expanded due to the light that was produced in Gen 1:3, this expansion resulted from a single to divisions of dense energy which later on becomes galaxies in the vast universe, of course this include our solar system.
Take note that the days in this creation were not really a literal day but a division of a process by process creation which was needed for the next phase of creation.
In 2 Peter 3:8, 1 day to the Lord is LIKE a thousand years. Does it mean that 1 day = 1000 years? The text says ‘one day is like [or as] a thousand years’—the word ‘like’ (or ‘as’) shows that it is a figure of speech, called a simile, to teach that God is outside of time (because He is the Creator of time itself). In fact, the figure of speech is so effective in its intended aim precisely because the day is literal and contrasts so vividly with 1000 years—to the eternal Creator of time, a short period of time and a long period of time may as well be the same. Meaning, a day to the lord may range from day 1 to billion years.
Going back still on the first day, every mass of earth or the division of dense energy has there own illumination due to the light that was produced in Gen 1:3. The heaviest of them were placed in the center creating a warped in space, and creating a perfect system where all lesser mass revolves around the center balancing each other so that a mass of earth or planet will not move or hit the center rather will keep rotating around it.
On the second day, the creator cause to divide the water that surrounds every planet. Kinda like in a nucleus, the nucleoplasm was divided into 2 from the center. The top surface over time developed to become protection on the inner layer of the earth, the bottom surface becomes the oceans of the earth. Our planet which we call earth was located on a perfect spot to balance the heat and cold and a perfect location for life.
On the 3rd day, the creator put some vegetation to the earth, now remember that for plants to survive it needs photons, not necessarily from the sun but of any light that produces photons, remember that when the creator caused the land of mass to expand subdividing it through a light, this light somehow remains in each planet, meaning, initially, planets have their own illumination kinda like stars we see at night enough for plants to get their sustenance. Plants were made to grow on this day prior to any creatures because plants produces oxygen, which is a pre-requisite for the next phase of creation.
On the 4th day, the creator created the sun by transferring all the illumination of each planet to the center, here, the sun becomes the brightest among all the masses in our solar system providing lights to all the planets, the moon channel this light during night time.
Then, the 5th day, this is where the earth finally became viable for creatures to live on earth, living creatures in water were made to appear.
And, on the 6th day, land creatures were made to appear and last are humans. It’s like everything was made first for humans ton dominate.
On the 7th day, the creator rested, the rest is history.