What is the difference between “vivre” and “habiter”? It seems that they both mean “to live“? But, when to use each?
"vivre" corresponds to the general abstract meaning of "to live". "Habiter" is the restricted sense of living at one particular place. As a rule of thumb, you can always use "vivre" instead of "habiter", but the reverse is not always true. More precisely, you can only use "habiter" when you want to say "to live somewhere".
"Je vis dans cette maison" : OK
"J'habite dans cette maison" : OK (the meaning is the same)
"Je vis une belle vie" : OK
"J'habite une belle vie" : makes no sense
"habiter" can also be used in a metaphorical sense, such as "Une passion m'habite" (Roughly translated "A passion is inside me"). This is still somehow related to the notion of living somewhere. Thanks to Stephane Gimenez for this remark.
Vivre is the general translation of live, as in, what you go through until you die.
Habiter specifically refers to one's home. (The verb also has other, related, less common meanings.) Both vivre and habiter can be used in the sense of having one's home in a particular place. There is a nuance between them: habiter refers strictly to one's home, whereas vivre generally covers a larger area that includes the place where you work, shop, etc. Thus habiter tends to be used with more precise indications of locations, while vivre tends to be used with less precise indications.
Here are a few examples.
Vivre is related the fact of existing or being alive.
Habiter is related to a geographical location where you live or exist.
Even if people use them most of the time as the same they don't have the same meaning. Vivre has a larger one.
Vivre has the meaning of existing
Haviter is a location where someone or something can stay, live, or exist