Ecc 3:19
For that which befalleth the sons of men befalleth beasts; even one thing befalleth them: as the one dieth, so dieth the other; yea, they have all one breath; so that a man hath no preeminence above a beast: for all
is vanity.
Ecc 3:20
All go unto one place; all are of the dust, and all turn to dust again.
Ecc 3:21
Who knoweth the spirit of man that goeth upward, and the spirit of the beast that goeth downward to the earth?
First of all, the overriding theme of the book of Ecclesiastes is this:
Ecc 1:2
Vanity of vanities, saith the Preacher, vanity of vanities; all
is vanity.
Ecc 12:8
Vanity of vanities, saith the preacher; all
is vanity.
Solomon utters these words at the beginning of his discourse, and he utters them near the end of his discourse as well, so everything that he said should be considered within such parameters.
In the verses in question, Solomon rightly notes that man, to a rather large degree, really has no preeminence over a beast or animal in that both will ultimately die, and their bodies will return to the dust from which they were originally made. I need to point out that verse 21 may not be accurately translated in the KJV. In other words, in just about every other Bible translation, the question really is "Who knows IF the spirit of man goes upward, and IF the spirit of the beast goes downward to the earth?" You can see this for yourself by simply clicking on this link.
https://biblehub.com/ecclesiastes/3-21.htm
When it comes to man's spirit at death, we know, from other portions of scripture in the Bible, that it does not automatically go upward. Here are some things to consider in relation to a Christian's spirit and what happens to it at death.
2Co 5:1
For we know that if our earthly house of
this tabernacle were dissolved, we have a building of God, an house not made with hands, eternal in the heavens.
2Co 5:2
For in this we groan, earnestly desiring to be clothed upon with our house which is from heaven:
2Co 5:3
If so be that being clothed we shall not be found naked.
2Co 5:4
For we that are in
this tabernacle do groan, being burdened: not for that we would be unclothed, but clothed upon, that mortality might be swallowed up of life.
2Co 5:5
Now he that hath wrought us for the selfsame thing
is God, who also hath given unto us the earnest of the Spirit.
2Co 5:6
Therefore
we are always confident, knowing that, whilst we are at home in the body, we are absent from the Lord:
2Co 5:7
(For we walk by faith, not by sight)
2Co 5:8
We are confident,
I say, and willing rather to be absent from the body, and to be present with the Lord.
In the context of describing the Christian's hope of receiving a glorified body at Christ's return, Paul said that he was wiling to be absent from his earthly body through death, so that he might be present with the Lord. Well, where is the Lord? He is seated at the Father's right hand in what the Bible calls
the third heaven (2 Cor. 12:2), so Paul apparently believed that a Christian's spirit and soul would go to be with God and Christ in heaven until the time of Christ's return when they will receive glorified bodies. Elsewhere, Paul said something very similar.
Phl 1:21
For to me to live
is Christ, and to die
is gain.
Phl 1:22
But if I live in the flesh, this
is the fruit of my labour: yet what I shall choose I wot not.
Phl 1:23
For I am in a strait betwixt two, having a desire to depart, and to be with Christ; which is far better:
Phl 1:24
Nevertheless to abide in the flesh
is more needful for you.
Here, Paul said that, for a Christian, to die is gain. Why? Because he fully believed that at death, or when he departed this world, he would be with Christ, which is far better than remaining in his earthly body here on earth. Again, where is Christ? He is seated at the Father's right hand in
the third heaven (2 Cor. 12:2), and this is where Paul expected his spirit and soul to go when he died.
Well, what about the spirit and soul of a non-believer? Where do they go upon death? From what scripture teaches, they go to hell or hades until the time of the second resurrection or until the time of
the resurrection of damnation (John 5:24). After that resurrection, they will be
cast into the lake of fire (Rev. 20:13-15).
As far as the spirits of beasts or animals are concerned, do "All Dogs Go to Heaven" as a popular movie suggests? From what I see in scripture, I honestly do not believe that they do. That said, all of creation, the animal kingdom included, will be delivered from the bondage of corruption after Christ returns.
Rom 8:18
For I reckon that the sufferings of this present time
are not worthy
to be compared with the glory which shall be revealed in us.
Rom 8:19
For the earnest expectation of the creature waiteth for the manifestation of the sons of God.
Rom 8:20
For the creature was made subject to vanity, not willingly, but by reason of him who hath subjected
the same in hope,
Rom 8:21
Because the creature itself also shall be delivered from the bondage of corruption into the glorious liberty of the children of God.
Rom 8:22
For we know that the whole creation groaneth and travaileth in pain together until now.
Here, Paul likened all of creation to a woman in labor. When Adam sinned, all of creation was made subject to vanity by reason of what he had done, and this certainly includes the animal kingdom.
Gen 3:14
And the LORD God said unto the serpent, Because thou hast done this, thou
art cursed above all cattle, and above every beast of the field; upon thy belly shalt thou go, and dust shalt thou eat all the days of thy life:
God did not just curse the serpent. Instead, the serpent was cursed above all cattle, and above every beast of the field. In other words, they were cursed too, but just not to the same degree that the serpent was. When Christ returns, the creature itself shall be delivered from the bondage of corruption, so there will be great changes to the animal kingdom.
We get a glimpse of that here.
Isa 11:6
The wolf also shall dwell with the lamb, and the leopard shall lie down with the kid; and the calf and the young lion and the fatling together; and a little child shall lead them.
Isa 11:7
And the cow and the bear shall feed; their young ones shall lie down together: and the lion shall eat straw like the ox.
Isa 11:8
And the sucking child shall play on the hole of the asp, and the weaned child shall put his hand on the cockatrice' den.
Isa 11:9
They shall not hurt nor destroy in all my holy mountain: for the earth shall be full of the knowledge of the LORD, as the waters cover the sea.
I hope that this helps to answer your question.
Ecc 12:13
Let us hear the conclusion of the whole matter: Fear God, and keep his commandments: for this
is the whole
duty of man.
Ecc 12:14
For God shall bring every work into judgment, with every secret thing, whether
it be good, or whether
it be evil.