I am not the best person to answer this. I believe that Solomon is concentrating on the flesh here as in contrast to the spirit. A man's body goes back to dust the same as for the beasts. It is vanity for us to think of ourselves more highly than we should. God blessed us in that we are made in his image, but we had no part in that. Solomon did say our spirit goes upward in contrast to the spirit of the beast, which goes downward.
What happens if a person dies? If we have accepted Jesus as our Lord and Saviour and our born again, we get to be with him eternally. If a child dies have no fear. God desires that no one is lost. You can rest assured that God is good, God always does what is right, and what is just.
Solomon was a unique individual. He was the wisest man that lived, and yet quite disobedient. He is an oxymoron of study.