"All things come alike to all: One event happens to the righteous and the wicked; to the good, the clean, and the unclean; to him who sacrifices and him who does not sacrifice. As is the good, so is the sinner; he who takes an oath as he who fears an oath. There is an evil in all that is done under the sun: that one thing happens to all..." (9:2,3). Death does not discriminate; it happens to all--even those who are good (cf. Heb. 9:27)! From a physical perspective, this does not seem fair, but it is reality nevertheless.
Solomon does not teach in Ecclesiastes 9:4-6 that one is annihilated at the point of death. From a strictly physical viewpoint, those who die have "no more reward" in that they no longer share in the activities of this planet. They "know nothing" only as it pertains to what is going on among the living (e.g., Luke 16:19ff). Clearly, we must take advantage of life today, for there may be no tomorrow, and after death comes, it will be too late. While one is alive, there is always the "hope" that he will do what is right with his physical life.
Those who are faithful turn their lives over to God and are able to enjoy a fulfilled life. They can eat cheerfully, knowing they are accepted by God (Eccl. 9:7). In context, the white garments of 9:8 do not refer to purity. Rather, in a hot climate, white clothing simply makes one feel more comfortable. His point is that it is appropriate to make oneself physically comfortable.
9:9 states - "Live joyfully with the wife whom you love all the days of your vain life which He has given you under the sun, all your days of vanity; for that is your portion in life, and in the labor which you perform under the sun." Man needs to enjoy hard work as well as his marriage all his days. This implies a serious commitment to one's spouse.
In 9:10, Solomon exhorts - "Whatever your hand finds to do, do it with your might." Without the contentment, comfort, and companionship discussed in the three prior verses, one will find it difficult to truly give his all. From the physical perspective, our opportunities to give our all are over at death.
We learn from 9:11--as well as from our personal experiences--that nothing is guaranteed in physical life - "The race is not to the swift, nor the battle to the strong, nor bread to the wise, nor riches to men of understanding, nor favor to men of skill; but time and chance happen to them all." The one who is fastest doesn't always win the race, and the best fighting man may still be the one killed (remember Goliath?). The wise man may not have any food on his table, and he who is perceptive and intelligent will not necessarily be wealthy. Also, the one with the greatest ability may not be shown favor (by kings, bosses, etc.). "Time and chance" (i.e., unexpected events) affect us all, and that is why there are no guarantees, physically speaking. Even death itself is unpredictable, inescapable, and abrupt (9:12).
The chapter closes by stressing the value of wisdom. Solomon presents an illustration of a city with two negatives: (1) it is small, and (2) it has few men to protect it. This city is facing a great king with an army (9:14). There was a poor wise man in the city. He could have delivered the city by his wisdom, but it appears that no one listened to him (9:15,16). It is unfortunately still true today that many foolishly equate poverty with ignorance.
When a person replies in a quiet and calm manner, it typically indicates wisdom and self-control. However, the ruler who wants to be heard will shout. Quietness implies confidence and should be listened to carefully (9:17).
Solomon then commented in 9:18 that wisdom is powerful, but, tragically, not as powerful as the destructive influence of a sinner.