The line you are referring to is more easily understood in the context of the full stanza.
We look before and after,
And pine for what is not:
Our sincerest laughter
With some pain is fraught;
Our sweetest songs are those that tell of saddest thought.
Earlier in the poem, the speaker was describing the cushy life and carefree joy a skylark experiences. Now the speaker is contrasting what it means to be a skylark with what it means to be human. Unlike a skylark, humans are without the ability to ever be entirely overflowing with happiness at all times. We will always look at the past and the future, wishing we had what we do not -- it is quite an awful fate compared to a skylark's lot in life.
However, it is not all bad. In the next stanza, the speaker explains that if humankind could we would put aside the things that make us miserable in life.
Yet if we could scorn
Hate, and pride, and fear;
If we were things born
Not to shed a tear,
I know not how thy joy we ever should come near.
The only catch is that if we were born to never feel sadness, we would thus never come near joy as exuberant as the skylark's joy. Without sadness, how would one know joy? Without pain how would one know comfort?
Our sweetest songs are those that tell of saddest thought because without intense sadness we would never know intense happiness. For instance, every hero must go through pain and trials to reach their goal and be victorious -- the victory would be far less sweet if they had suffered less in trying to attain their goal.