The main difference between morar and viver in Portuguese is:
Morar means to reside or dwell somewhere more temporarily or physically. It refers specifically to where one has their home or lives at a certain address.
Examples:
“Eu moro em São Paulo.” (I reside in São Paulo.)
“Ele morava na casa ao lado.” (He used to live in the house next door.)
Viver means to live or to be alive in a broader, more continuous sense. It refers more to one’s experience of life overall or in a particular place.
Examples:
“Ela já viveu no exterior.” (She has lived abroad before.)
“Como você vem vivendo?” (How have you been living/how is your life going?)
“Enquanto ele viver, estará conosco.” (As long as he lives, he will be with us.)
So in summary:
Morar is used for the place of physical residence or dwelling.
Viver is used to talk about experience of living or being alive in general, lifestyle, period of time one has lived somewhere, etc.
Both verbs are commonly used, but the nuance is that morar refers specifically to where one lives locally, while viver can be used more broadly about living one’s life.