Is this only about the earth?
The use of "earth" here is allegorical. It symbolizes the universe following creation. The Hebrew word being translated to earth is אֶרֶץ (erets). This can mean 'earth' or 'land' or 'territory.' It can also indicate an area or space. In the context of God's creation of the universe, we must widen our vision beyond just this one planet.
This understanding that the text refers to the physical universe is also appropriate since the text also says it was formless. Since it was formless, the object discussed must be the universe in general, rather than the earth, since the earth by default has form.
This verse explains that once the physical universe was created, it was vacant ("empty" or "void" from בהו (bohuw)) and without form ("formless" from תהו (tohuw)). From Genesis 1:1 we know that God had already created the foundation of the universe, so from this verse we can know that the Supreme Being had produced and brought together the atomic elements that would make up the universe, but they had yet to come into their molecular structures and eventual forms.
These include the elements, as well as the galaxies, solar systems and planets. They are all essentially made of molecules. In order for molecules to have structure, atoms must come together in particular formations, and the molecules must also come together into molecular formations such as lattices. This requires, according to physics, electromagnetic forces termed the strong forces and weak forces. The planets, solar systems and galaxies are also structured with similar forces. These include gravity and angular acceleration.
Since the universe had composition but no form, we know that God had yet to provide these forces that supply structure and form to atomic matter.
A fluid universe
We also know from this verse that prior to the structure and form, the universe was fluid. There are two mentions of fluidity here, first "the surface of the deep," and second, "the waters." So we know from these that prior to the formation of solid structures, the universe was fluid.
This only makes sense, because when atoms are further apart from each other, they have less structure, but they may retain fluidity if they are within the same container. Once outside forces are applied, this fluidity can change into structure. This infers that God had already supplied some forces - of fluidity among the atoms - but not the forces that provide solid structure.
It says that the "the Spirit of God was hovering over the waters." What does this mean? It is quite clear that God was present, not in His Original Form, but in an expanded form. How do we know that? If God was present in His Original Form, then it would say "God was hovering over the waters." But it didn't. It clearly says, רוּחַ (ruwach), which means 'spirit' or 'breath.' Therefore, one could also accurately translate the phrase to the "breath of God."
The breath of God
And what is the "breath" of someone? A person's breath emanates from the person. A person's breath is considered an outlying product of their person: an expansion of the person.
Notice that the word God here is translated from אֱלֹהִים (Elohiym). This is the Supreme Being's Holy Name. God's Holy Names are also an emanation of God.
Because the physical world is being managed by an emanation of God, we can know from this that God's Original Form must reside elsewhere - and not hovering over the waters of creation. Where is this place that God resides in His Personal Form? This can only be the spiritual world.
So rather than envisioning some sort of a ghost hovering over the water, we are talking about a practical matter, of God being present during creation through an expansion of Himself through His facilities.
This might be comparable to a chief executive of a multi-national corporation who decides to build a plant in a foreign country. Once he authorizes the building of the facility, he does not need to personally go out to the country and start stacking bricks. He can have others doing that. But through his directives and his oversight, the chief executive's orders are followed through, using various sub-contracting companies and builders. It is still his plant, and we can say he built it, because he authorized it, directed it and oversaw its building. But he didn't have to do everything himself.
In the same way, the Supreme Being does not have to be present in His Personal Form to build the physical universe. He authorizes it, and all of the resources originate from Him. But He can still be attending to His personal matters while the universe is put together. This is because He is God, the Source of not only existence, but every living thing. Therefore, God must also be alive. He must also be a Person, since nothing comes from nothing.
We can see this in effect today, as the physical universe appears to operate as though it is on automatic. It has a machine-like quality, with gears, power and motion. The original machine of the physical universe was designed and programmed by God. Then God's facilities were put in place and it began to run like a big machine.