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".
I live in this house
"Je vis dans cette maison" : OK
"J'habite dans cette maison" : OK (the meaning is the same)
I live a beautiful life
"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.
Je vis en France depuis trois ans.
I've been living in France for three years.
(“J'habite …” is also possible, but gives a slight administrative vibe.)
Je vis à Paris.
I live in Paris. (Probably includes the suburbs, but could also mean just the municipality.)
J'habite à Paris.
I live in Paris. (Probably means the municipality, but could also mean the whole region.)
J'habite dans le cinquième arrondissement.
I live in the 5th arrondissement.
(“Je vis …” would give the impression that you never get out of the arrondissement.)
J'habite au cinquième [étage].
I live on the fifth floor.
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
Habiter is a location where someone or something can stay, live, or exist