We read about God's creation of the heavens and the earth in Genesis 1.
Genesis 1:9-10 (The Third Day)
Then God said, "Let the waters below the heavens be gathered into one place, and let the dry land appear"; and it was so. God called the dry land earth, and the gathering of the waters He called seas; and God saw that it was good.
Genesis 1:16-18 (The Fourth Day)
God made the two great lights, the greater light to govern the day, and the lesser light to govern the night; He made the stars also. God placed them in the expanse of the heavens to give light on the earth, and to govern the day and the night, and to separate the light from the darkness; and God saw that it was good.
There's nothing logically incoherent about the earth existing before the sun. However, many people believe that the sun is older than the earth, and we generally speak of the earth's position in space as being in orbit around the sun.
If, as many people believe, the sun is older than the earth, then the sun has existed longer than the earth, and if the Bible says it has not, then the Bible would be wrong.
Also, if the earth's location in space has always been properly defined by its relationship to the sun, but the Bible says there was a time when there was an earth but no sun, then the Bible must be wrong.
It's my guess that these inconsistencies are what the question is referring to. But again, keep in mind that there is nothing illogical or logically incoherent about the earth existing prior to the sun. It's just something that lots of people don't believe to be true.
But why should the random and changing whimsical opinions of lost and confused humanity be permitted to be the ultimate judge of reality? If it's all we have to go on, then sure, why not, but when we have the authoritative word of God spelling things out for us, there is no reason to put our blind faith in people's personal opinions.
What are the reasons so many people have decided that the sun came before the earth?
I honestly don't know all of the reasons (and maybe not any of them), but I feel perfectly comfortable hazarding some ignorantly vague guesses.
1. We've tested the mineral content of various rocks and compared the numbers with observed radioactive decomposition rates, thereby determining when the rocks were formed, ie, the age of the earth.
2. We've analyzed the light spectrum coming from the sun to determine its chemical composition and compared that also with radioactive decay rates that have been observed, thereby determining the age of the sun.
3. We've proceeded from numerous theories about the formulation of solar systems and galaxies, the big bang, etc, checking vector paths based on current trajectories and so on and so forth, to determine when our sun would have come into being.
I dunno... probably a bunch of stuff along those lines. In other words, we have not drawn our conclusions about the length of time the earth and the sun have been around based upon first-hand witness -- rather, we have drawn our conclusions based on observations of existing phenomena.
This is kind of like trying to deduce how old a person is based on how tall they are, or the color of their hair, or the length of their fingernails, or how many teeth they have, rather than by witnessing their birth and counting each day and year thereafter.
While this kind of guesswork can often produce amazingly accurate results, sometimes it fails miserably, and I'm sure we all have anecdotes that we could share to prove it.
Now imagine that God actually created Adam as a full grown man, as the Bible seems to suggest.
If we were to look at Adam three seconds after he was created, we may guess, based on his height, his teeth, his hair, etc, that he had been around for 20 or 30 years. Of course, we would be wrong, and God Himself has clearly told us as much in the Bible.
The Bible suggests that God created Adam fully mature, that God created the animals fully mature, and that God created the plants fully mature. We see a pattern developing here. Why would we not also conclude that God created the universe fully mature?
We have a mature sun and a mature earth -- not because they are old, but rather because God created them fully mature, quite possibly so that they would immediately be capable of sustaining life.
This in no way, shape, or form contradicts any of the evidence available -- it only contradicts certain individuals' interpretations of the evidence.