In the beginning, God made it clear that we are from dust and to dust we will return. This concept remained the dominant theology prior to the revelations of the prophets. With the revelations from the prophets (Daniel, Isaiah, Ezekiel, etc.), Judaism moved into the realization of eternal life. With Jesus came a much fuller understanding of what happens to us after death.
Sheol
The idea that persisted throughout early Judaism is that when people died, they went to a place called Sheol. Modern translations sometimes translate this original Hebrew word as "pit" or "grave". However, it's clear from Ecclesiastes that this falls far short of the true answer. It's very clear that it exists as a place of nothingness.
In Sheol, there is no
It's clear from these verses that Sheol is a place of nothingness.
This is further supported by the following passages:
Genesis 3:19 (NASB)
By the sweat of your face You will eat bread,
Till you return to the ground, Because from it you were taken;
For you are dust, And to dust you shall return.”
It's further supported that this place is a place where all people go, regardless of their deeds (in support of the Ecclesiastes 9:2 from the question):
Job 3:11, 17-19 (NASB)
11 “Why did I not die [a]at birth, Come forth from the womb and expire?
17 “There the wicked cease from raging, And there the weary are at rest.
18 “The prisoners are at ease together; They do not hear the voice of the taskmaster.
19 “The small and the great are there, And the slave is free from his master.
Furthermore,
Psalms 6:5 (NASB)
For there is no mention of You in death; In Sheol who will give You thanks?
We also see this in Psalms 88:3-12 (although too long to quote here).
In Essence
The idea that existed back then (when Ecclesiastes was written) is that Sheol is essentially a place of nothingness, a shade of an existence where there is no memory and no reward.
Rise of the Prophets
It wasn't until God gave us revelations through prophets like Daniel, Isaiah, and Ezekiel that the idea of true life after death came to be understood.
For example, revelations to Daniel showed that there will be a place of eternal reward established:
Daniel 2:44 (NASB)
In the days of those kings the God of heaven will set up a kingdom which will never be destroyed, and that kingdom will not be left for another people; it will crush and put an end to all these kingdoms, but it will itself endure forever.
However, it wasn't until these revelations by God that we understood that there was more to life after death than simply Sheol.
See also: Wikipedia: Jewish eschatology
Christianity and Heaven
As Judaism slowly moved from these ideas of Sheol (nothingness after death) into an understanding of life after death, Jesus came on the scene and established his kingdom.
I won't bother rehashing all the details there. However, Jesus fulfilled many of the prophecies of Isiah. Now he's off, preparing a place for us. Since that time, God revealed even more about heaven and hell in the Book of Revelations.
Summary
Prior to the prophets, the idea of eternal existence beyond life simply boiled down to nothingness. It wasn't until God revealed the truth to us through his prophets that we understood the realities of heaven and hell. At the time of Jesus, these ideas of eternal life were somewhat present, but still vague. Jesus, who had come from heaven, told us many things about heaven and hell. Even more was revealed to us through the Holy Spirit and through the Revelation of John.