1. The origin of the custom: Two main theories:
2. Origins of the phrase, 'Nitl Nacht': Possibilities include:
For everything else you ever wanted to know about Nitl Nacht -- including strange customs and jokes (!), there's Ha'aretz. Extensive correspondence on the topic (including several paragraphs which I've shamelessly plagiarised above) here, here and here .