This poem captures the way that Nature works to give solace and companionship to mankind in the manner that it seeks to sustain man and support him, whatever his feelings or emotions. The very first stanza explores how Nature does this:
To him who in love of Nature hold
Communion with her visible forms, she speaks
A various language; for his gayer hours
She has a voice of gladness, and a smile
And eloquence of beauty
This is saying that Nature is able to speak in a number of different ways to those who communicate with her. In particular, Nature seems to possess the ability to act like a mirror: when we are happy, Nature reflects our own happiness with her beauty and harmony. Likewise, when we are sad or depressed, Nature seeks to encourage us by being a solace and a healing force. It is important to realise that Nature is presented in this poem as some kind of exterior force that is shown to act for the good of humanity, and whom we will rejoin at the end of our life.
At the beginning of "Thanatopsis," the speaker is experiencing happiness ("gayer hours") and this prompts a very specific reaction from Nature, who is personified as a female friend. First of all, Nature's voice is full of "gladness," which means that it is happy, light, and upbeat. In addition, she smiles a lot and her natural beauty is very obvious and apparent.
When the speaker is happy, Nature also moves in a very specific way: she "glides," for example, and is able to penetrate his darker thoughts ("musings") and make their "sharpness" go away. In other words, she neutralizes his bad thoughts and turns them into good. She therefore possesses the power of healing.
In essence, Nature reacts to the speaker's mood: when he is happy, she acts in a way to prolong this feeling and, when he starts to feel sadness, she intervenes to take his negative thoughts away.