How can a happy nature psalm be a song about the day of death?
At first glance this psalm has nothing to do with death. Springs run between hills, cedars grow, a stork nests in a juniper. Yet the Gemara says David sang the first verse when he looked at the day of death.
The Gemara says David lived in five worlds and sang in each, and the first verse of this psalm is the song of the last one, the day of death. When the Gemara asks how it knows, it points to verse 29: "You hide Your face, they are terrified. You take away their breath, they die and return to dust."
Read one verse further and the picture is not only grim. Verse 30 says: "You send Your breath, they are created, and You renew the face of the earth." The psalm puts dying and new life in back-to-back verses.
Radak (Rabbi David Kimchi of southern France, about 800 years ago) adds a point about the opening words. This psalm is about how the world was made, he writes, and in the lower world nobody knows how to bless God except the thinking soul of a person. That is why the psalm begins by talking to the soul.
The Gemara gives only the proof from verse 29. It does not say more about why these opening words fit the day of death. That part stays open.
Berakhot 10a,Tehillim 104:29-30,Radak on Tehillim 104:1The psalm says the earth will never move. What is it even standing on?
Verse 5 says God set the earth on its foundations so that it will never be moved. Today we know the earth spins and circles the sun. So what did the sages think the foundations were, and what do these words mean?
The Gemara has a whole discussion. Rabbi Yose says: "Woe to the creatures that see and do not know what they see, that stand and do not know what they stand on." Then he gives a chain. The earth stands on pillars. The pillars stand on water. The water stands on mountains, which is a line from verse 6 of our psalm. The mountains stand on wind, the wind on storm, and the storm hangs on God's arm. Other sages say twelve pillars, or seven, or a single pillar named "Righteous," from the verse "a righteous person is the foundation of the world." The Gemara lists these and picks none.
Two medieval commentators went another way. Radak says it is in the earth's nature to fall toward the lowest place, which is the center of the heavens, so it sits there like a ball, leaning to no side. Ibn Ezra says the earth has no motion, because next to the heavens it is like a point inside a circle.
Neither of them thought the earth moved. They explained the verse with the best astronomy of their day, and they gave different reasons. The Gemara knew this could happen. In Pesachim, Rabbi Yehuda HaNasi (the editor of the Mishnah) argued against the sages of the nations on one question. On another, where the sun goes at night, he said their view looked more accurate than the Sages', because springs are cold by day and hot at night.
So none of these sources knew what we know, and none answers your question directly. Notice, though, where the psalm goes next. It praises God for setting a boundary the waters cannot cross, so they will not come back and cover the earth (verse 9). Radak says that boundary is the sand at the edge of the sea.
Tehillim 104:5-9,Chagigah 12b,Radak and Ibn Ezra on Tehillim 104:5,Pesachim 94b,Radak on Tehillim 104:9Is the whole world here for humans? What are mountain goats for?
Look at what verses 10 to 18 describe. Springs for wild donkeys that live in the desert. Cedars no person planted. A stork in a juniper. High mountains for mountain goats. Little of it is for people. So who is it for?
Radak notices how deliberate this is. Verse 11 names the wild donkeys because they stay in the desert and never come to settled places. Verse 16 calls the cedars "trees of Hashem" because no human effort made them grow. Yet on verse 18 he also writes that nothing small was made except to benefit something bigger than itself, "and all of it is for the benefit of man, who is above them all."
Rambam (Maimonides, who lived in Egypt in the 1100s, a little before Radak) saw it differently. In the Guide for the Perplexed, his book of Jewish philosophy, he asks whether God could have made a person without all these preparations. The right view, he says, is not to believe that everything exists for human beings. The rest also exist for themselves, not for anything else. He adds that some things exist so that others can exist.
The book of Iyov (Job) has a similar picture. When God finally answers Iyov, it is out of a storm, with questions about wild creatures and places no one controls. "Do you know when the mountain goats give birth?" "Who sent the wild donkey out free?" And about rain: to make it fall "on a land where no one lives, a desert with no person in it."
So the sources hold more than one answer. Radak sees a ladder where each thing serves what is above it, ending with people. Rambam says the world is not only about us, and the questions from the storm seem to point the same way, though they never say it in so many words. The sources do not settle it.
Tehillim 104:10-18,Radak on Tehillim 104:11, 104:16 and 104:18,Rambam, Guide for the Perplexed 3:13,Iyov 38:26 and 39:1-5