For なぜ:
Very very directly asks for a reason. (Which is why なぜ appears the rudest)
For when you really intend to be direct. "No bullshit, tell me the reason now".
For どうして:
Deconstructing どうして yields どう(which way/manner) + して(Verb conjunctive form of する)
どうする (Which way/manner of doing?)
どうして[X] (Which way/manner of doing did X come to be?) Which is functionally equivalent to "why" since you indirectly ask for a cause of [X]. Also functions as a "how" since you ask for the way/manner of doing it.
For 何で:
何 (What)
で (Instrumental particle)
何で (By what means) Which is functionally equivalent to "how"
"how" is a specific concept separate from "why" but share some similarities:
Question: Why? - Type of Response: Reason, Cause, Use of Method(is a subset of Cause)
Question: How? - Type of Response: Method
Simple illustration of the slight overlap:
Why does it work? - It works because this method is being used.
How does it work? - It works through this method.
Interchangeability:
Following my above assessment of どうして performing both functions of "why" and "how" and 何で for a functionally equivalent "how",
I would say that 何で may be replaced with どうして but どうして may not always be replaced by 何で. (However I do not know enough about the difference in nuance between them.)
None of them does the exact same thing as なぜ though, なぜ's nuance is its directness.