Why does the Bible say that when we die our spirit returns to God (Ecclesiastes) and we read the story of the rich man and Lazarus that seems to be in a different location?
"Remember your Creator before the silver cord is loosed, Or the golden bowl is broken, Or the pitcher shattered at the fountain, Or the wheel broken at the well. Then the dust will return to the earth as it was, And the spirit will return to God who gave it" (Ecclesiastes 12:6-7).
A contrast is being made between what happens to a person's physical body and his spirit. The body returns to the earth, but no details are given as to how or where it goes back to the earth. The spirit returns to God, but again no details are given. This is a general statement designed to emphasize that physical things return to physical places and spiritual things returns to spiritual places. "It is sown a natural body, it is raised a spiritual body. There is a natural body, and there is a spiritual body" (I Corinthians 15:44).
Jesus gives us greater detail about how and where the spiritual part of use returns to the spiritual realm in Luke 16:19-31. We learn that there is a waiting place called hades that has two divisions. But this too doesn't tell us everything because hades is not the final destination of the spirits of men. "Do not marvel at this; for the hour is coming in which all who are in the graves will hear His voice and come forth -- those who have done good, to the resurrection of life, and those who have done evil, to the resurrection of condemnation" (John 5:28-29). When the spirits come from the place of waiting, there will be a judgment. "When the Son of Man comes in His glory, and all the holy angels with Him, then He will sit on the throne of His glory. All the nations will be gathered before Him, and He will separate them one from another, as a shepherd divides his sheep from the goats" (Matthew 25:31-32). So eventually all who died will return literally to God for their final judgment. "For we must all appear before the judgment seat of Christ, that each one may receive the things done in the body, according to what he has done, whether good or bad" (II Corinthians 5:10).
Notice there is no conflict with what Solomon stated in Ecclesiastes because Solomon didn't say the spirits immediate appear before God only that they will go back to God.