Japanese is so vocabulary rich that knowing when to use similar words and phrases can be a bit of a nightmare for language learners. どうして, なぜ and なんで can all be translated as ‘why’ in English but it is the level of formality which largely differentiates the three words.
なぜ orginated from the older term なにゆえ. It is the most formal of the three and is the word most often used in the written language rather than in speech.
なぜ日本語を勉強していますか? naze nihongo wo benkyou shiteimasuka?
Why are you studying Japanese?
なぜ昨日のパーティーに来なかったの? naze pa-ti- ni konakatta no?
Why didn’t you come to the party yesterday?
In a lot of cases, どうして can be used interchangeably with なぜ, but is considered to feel less formal. The word is a contraction of an older term どのようにして, and therefore can sometimes be used to mean ‘how’ rather than why’ in English.
どうして知っているの? doushite shitteiru no?
How did you know?
どうして昨日そんなに早く帰ってしまったの? doushite kinou sonna ni hayaku kaette shimatta no?
Why did you go home so early yesterday?
なんで is the most informal of the three terms. As you can imagine, this word tends to be used more by young people than other age groups.
なんで私が? nande watashi ga?
なんでそんな所に行ったの? nande sonna tokoro ni itta no?
Why did you go to that place?
どうして is probably the word you’ll hear used the most and is therefore your safest bet for everyday use, but make sure to choose wisely depending on what setting you are in.