Viktor E. Frankl said this quote

There is nothing in the world, I venture to say, that would so effectively help one to survive even the worst conditions as the knowledge that there is a meaning in one's life. There is much wisdom in the words of Nietzsche: He who has a why to live for can bear almost any how