Here is the quote from Friedrich Nietzsche:
He who has a why to live for can bear almost any how.
I don't quite understand it, especially this phrase
almost any how. Can somebody please shed light onto the meaning?
He who has a WHY to live can bear almost any HOW (to live)
It's a very colloquial way of saying
He who has a REASON to live can bear almost any MANNER of life.
If you have a reason or purpose in life, you can endure almost any misery.
ADDED, to address orthographic issues raised in the Comments:
I have been unable to find the original edition or a critical edition online; but scholarly references appear to use this:
Hat man sein w a r u m ? des Lebens, so verträgt man sich fast mit jedem w i e ? – Der Mensch strebt nicht nach Glück; nur der Engländer thut das.
There are no quotation marks, but warum? (why?) and wie? (how?) are letterspaced. This is a common emphatic device in German orthography; Bernard Shaw was fond of it, too. Some contemporary writers follow another of Shaw's favorite uses with embedded quotations and capitalise these terms (Warum? Wie?) instead; but in German this marks them as nouns.
A translation which preserves Nietzsche's aggressive colloquialism might be:
If you have your Why? of life, you can put up with just about any How? —Man doesn't strive for happiness; only the Englishman does that.
(The last bit of snark is probably not a nationalist sneer but a joke mocking English philosopher Jeremy Bentham and his ‘felicific calculus’.)
In the example sentence, why and how are set up in a parallelism, to be understood as:
He who has a why to live can bear almost any how to live.
Like the original example, this is not actually, formally, grammatically correct. It is a poetic expression. It might be better understood written as:
He who has a why-to-live can bear almost any how-to-live.
What is "a why-to-live"? Idiomatically, "a why" is a reason, so this means a reason to live. Thus by parallelism (and this is not idiomatic) "a how" is a means, and "any how-to-live" is "any means to live".
Thus it poetically and concisely expresses the idea:
He who has a reason to live can bear almost any means of living.
Victor Frankel's, "Mans Search for Meaning" Will explain this quote absolutely. While living through Auschwitz, Frankel discovered that those victims who had meaning in their lives were far more likely to survive than those who did not.
When EVERYTHING is taken from you, leaving no possibility of any kind of normal "happiness", if you still had a sense of "why", a sense of meaning, will get you through the day.
I actually found this quote when trying to understand the importance of the simple question 'WHY' in the workplace. My interpretation of this basically - If you can understand why a thing needs to be done, your solution or 'how' will be strategic to reach the goal of why the thing needs to be done, not just doing it.