When the bible says that God created the stars to give the earth light, there are also stars that we can't even see. Why would God create those stars if they don't light the earth?
There are several possible answers to your question. One is that the passage doesn’t say that the stars were to give light to the earth. Genesis 1:16 says, “And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.” This is the verse after he says he will make lights to give light to the earth. It is possible that the sun and the moon fulfill that role, and the mention of the “stars also” does not relate directly to the giving of light to the earth. It would be like saying he made the lights for the earth, and he made other lights as well.
A second possibility, based on the scientific evidence called the “red shift,” is that the stars are moving away from us at an increasing rate of speed. It is possible that the stars were originally such that they were all visible, but God caused the universe to expand and now some are beyond the range of giving light to the earth.
A third, less likely, possibility is that God realizes that all light sources eventually give some minimal amount of light to the earth, even though it may be so small as to be undetectable. This would mean that we would have to look at the Bible as an ultimately true science text, which it is not. While the science of the Bible is true, it is not designed to tell us such obscure data about the nature of light.