Nope is an informal form of no. It first appeared in writing in 1888, when the Oxford English Dictionary took note of its use in the May 12th issue of Life. It was no doubt used in spoken language long before that. Life used it as part of a dialog between an adult and a child, and it was, naturally, the child who used the informal 'nope'.
Originally it was a particularly emphatic way of saying no -- probably pronounced no-P!, with a strong popping of the P. Nowadays nope usually isn't used in an emphatic fashion. It's just the lazy persons' way of saying no.
Thanks to Oolong for checking the OED and providing the original dialog as it appeared in Life:
'I suppose you will be a literary man, like your father, when you grow up.'
`Nope,' said the little boy.. 'Literary nuthin'! I'm goin' to be a ten-thousand-dollar cook.'
NOPE is also one of the three Ns.
...and BANANA, of course.
NOPE stands for Not On Planet Earth. The idea being that some things just shouldn't be built on planet Earth. It's usually used to scornfully refer to people who want to do away with nuclear power plants, oil refineries, landfills, republicans, and other necessary evils of everyday life. ("Stupid NOPEs. How I hate them", for example). I've never seen NOPE pins or posters; it's not something people tend apply to themselves.
The 1737 dictionary of thieving slang defines Nope as a "blow" (hit) or a "Knock on the Pate"; "We hit him a Nope on the Costard".