Leo Rosten said this quote

The purpose of life is not to be happy—but to matter, to be productive, to be useful, to have it make some difference that you lived at all.