"I also thought, 'As for men, God tests them so that they may see that they are like the animals. Man's fate is like that of the animals; the same fate awaits them both: As one dies, so dies the other. All have the same breath; man has no advantage over the animal. Everything is meaningless. All go to the same place; all come from dust, and to dust all return. Who knows if the spirit of man rises upward and if the spirit of the animal goes down into the earth?'" NIV translation
Solomon saw that God tests men so that we can see that, in our physical life here on the earth, we are subject to death just like the animals are.
While we are alive on earth, we often have a sense of being in control but, as we get closer and closer to the end of our lives, we realize that God has numbered our days and we will die just like the animals. Do dogs go to heaven? Solomon did not have the answer.
"So I saw that there is nothing better for a man than to enjoy his work, because that is his lot. For who can bring him to see what will happen after him?" NIV translation
Solomon's conclusion about under the sun (physical) things and under the Son (spiritual)? Once we have our final destiny established through our faith in the Son, we can enjoy the things that God has for us to do while we are here on the earth.
We see far too many people (even Christians) trudging through this life with little joy. That is not what god has for us and that is not what He has set before us. If we ask Him what He wants us to do while we are here and we listen for His answer through the Holy Spirit, we will be where He wants us to be. When we are in the position that God has for us and doing what He has laid out for us to do, we can have the joy that Solomon spoke about in our work.