The first and most important point to note it that it's very informal (more so than using contractions such as my it's there, for example).
The main reason for using it at all stems from that "extreme informality". It normally conveys a relaxed attitude on the part of the speaker. Depending on context, it can be more or less emphatic than "No".
You only use nope to mean [my answer is] "No" – it never replaces no in any other contexts. And you wouldn't normally use it where you want to be very emphatic (shouting "No!" at the top of your voice). Which example illustrates a defining characteristic – "Nope" isn't often followed by an exclamation mark!
Finally, I'd echo John Lawler's words: "nope" occurs only as a one-word answer to Y/N questions. That's to say, a written form such as:
"Nope I don't want to"
doesn't look right. We expect a full stop (or at the very least a comma) after "Nope" because in real-world speech there always would be a pause there. But that doesn't happen with:
"No I don't want to!"
because it's perfectly possible to speak those words without pausing appreciably after "No" (without necessarily placing extra stress on "don't", either; I just italicised it as one possible enunciation).