Solomon shares his wisdom with us on this subject in verse 20. Ecclesiastes 3:18-22
18 I also said to myself, As for humans, God tests them so that they may see that they are like the animals. 19 Surely the fate of human beings is like that of the animals; the same fate awaits them both: As one dies, so dies the other. All have the same breath[c
]; humans have no advantage over animals. Everything is meaningless. 20 All go to the same place; all come from dust, and to dust all return. 21 Who knows if the human spirit rises upward and if the spirit of the animal goes down into the earth?
22 So I saw that there is nothing better for a person than to enjoy their work, because that is their lot. For who can bring them to see what will happen after them?
To borrow from Psalms:
For his anger is but for a moment,
And his favor is for a lifetime.
Weeping may tarry for the night,
But joy comes with the morning.