How can one live happily
How one can live happily
What is grammatically correct from the above two sentences and also let me know meaning for both the sentences.
The first one is a grammatical question. The second one reads more like a title than a question; it could be used as a header for a paragraph.
So, as an essay, you might see it like this:
How can one live happily? By learning to be content with what you have, and making the most of every day. A spirit of thankfulness helps as well.
How one can live happily
We can have a happier life when we learn to be be content with what we have, and make the most of every day. Keeping a thankful spirit helps, too.
In a dialog, we might start with the question form:
"Dad, how can one live happily?"
"Well, son, we can be happy by learning to be content with what we have, and making the most of every day. Staying thankful can help, too."
If you intend the clause to be a standalone question, then the first is okay:
"How can one live happily?" asked he, looking at the sky. (a standalone question)
In the first position we have the interrogative word "how", next goes the auxiliary verb "can", then the subject pronoun "one".
The second clause will only be okay in a headline (see J.R.'s answer) or as part of a bigger sentence:
Come here, son. I will tell you [how one can live happily].
Here, the part in brackets would be an "interrogative content clause".
Why do the two clauses differ? Because the first clause is an example of "subject-auxiliary inversion". The word one is the subject. The word can is an auxiliary verb. When you are just telling something, you usually place the subject first: SUB + AUX. But you sometimes invert their positions: AUX + SUB, for example, when you pose questions.
The second clause does not feature the inversion. It would fit in an indirect question sentence:
Could you tell me how one can live happily?
The same "indirect question" word order applies to reported questions:
She asked me how one can live happily.
.. and it could serve as a noun complement:
The question of [how one can live happily] has occupied man's thought for millenia.
.. and as an adjective complement:
Nobody is sure of [how one can live happily].
It can also be moved to the end of the sentence, with the expletive it taking its place:
[How one can live happily] is not known. --> It is not known [how one can live happily].
Compare with the question form, where there's a subject-auxiliary inversion:
How can one live happily? (AUX+SUB) - It is not known how one can live happily. (SUB+AUX)