Let's consider 3 possibilities:
- It's a contradiction
- The spirit returns to the presence of God
- The spirit returns to the realm of God
1. Contradiction
A textual analyst should be open to finding irreconcilable texts, but I suggest it is foolish to assume we are smarter than whoever wrote the text and that we readily spot things they were too simple to notice. We should first ask if there is a reasonable explanation that allows the possibility that the writer did know what they were talking about.
The case for contradiction finds further difficulty in the fact that the two texts we are considering here come from the same book. It's one matter to say author A & author B have different, irreconcilable worldviews...it's another to say the author (or compiler, if you like) of Ecclesiastes couldn't keep his story straight from one chapter to another.
2. The presence of God
The Old Testament is replete with passages indicating that Sheol is the place of the dead. A literal interpretation of Ecclesiastes 12:7 would suggest, then, that while in Sheol the spirit is in the presence of God.
Is it possible for God to be in Sheol? Or to visit? Hades is the Greek word (in LXX & NT) used for Sheol, and multiple early writers understood 1 Peter 3:18-20 to indicate that Jesus visited Hades:
18 For Christ also hath once suffered for sins, the just for the
unjust, that he might bring us to God, being put to death in the
flesh, but quickened by the Spirit:
19 By which also he went and preached unto the spirits in prison;
20 Which sometime were disobedient, when once the longsuffering of God
waited in the days of Noah, while the ark was a preparing, wherein
few, that is, eight souls were saved by water.
For example, Clement of Alexandria stated quite unambiguously:
The Lord preached the gospel to those in hades (Ante-Nicene Fathers
2:490)
If this is true, then it is possible for Deity to visit Sheol/Hades. Whether or not that is true just for the time period between the crucifixion & the resurrection, or true at other times as well, is not stated.
Polycarp appears to substantiate the possibility of the spirits of the dead being in the presence of God:
I exhort you all, therefore, to yield obedience to the word of
righteousness, and to exercise all patience, such as you have seen
[set] before your eyes, not only in the case of the blessed Ignatius,
and Zosimus, and Rufus, but also in others among yourselves, and in
Paul himself, and the rest of the apostles. [This do] in the assurance
that all these have not run in vain, but in faith and righteousness,
and that they are [now] in their due place in the presence of the Lord
(Epistle to the Philippians, chapter 9)
3. The realm of God
If I return something to a king, I could give it to him personally, or I could return it to his court without seeing him. As such, it is possible to return something to someone without seeing that someone.
That we will stand before God at the time of judgement (post-resurrection) is clear from Revelation 20:12, but the possibility of doing so prior is not clear from the Biblical text.
It is possible, however, that a viable explanation is found in the Psalms:
The heaven, even the heavens, are the Lord’s: but the earth hath he
given to the children of men. (Psalm 115:16)
The plural "heavens" (common in Hebrew) suggests--as Dottard has already alluded--that this may not be a reference to just one discrete place. If the heavens (or spiritual realm) are the Lord's realm and the earth is man's realm, then leaving earth and returning to some portion of that spiritual realm can be described as leaving man and returning to God (even if one is temporarily in an intermediate state and will go somewhere else later).
Conclusion
Possibilities 2 & 3 above are not entirely mutually exclusive. The Biblical text is unclear as to whether or not the spirits of the dead will be in the presence of God prior to their resurrection, even if a well-placed early source like Polycarp thought so, but there is no reason to doubt the consistent attestation that the dead go to Sheol.
I do not believe it is necessary to resort to contradiction here--a viable explanation exists that respects the intelligence of the author. It is possible for the spirits of men to return to the "heavens [which] are The Lord's", satisfying Ecclesiastes 12:7, without conclusively ruling out option 2 or option 3 above.
When we die, we go to the grave
- 1) Are you saying that "we" are our bodies? If so, what if you lose a leg? Would "you" still be you or 90% you? What if "you" lose your legs and your arms? Would that still be "you"? 2) What about Sheol?