As with many slang terms, we don't know for certain what inspired the first utterance of nig nog. We do however, have a very educated guess.
As early as 1533 the word nidiot was being used as a synonym for idiot. At about the same time nodcock was coming into common use to mean a fool (nod meant fool; -cock was used as a diminutive). It is possible, although far from certain, that these two words were combined into the word niddicock, which emerged around 1586 to mean a fool or an idiot. This may or may not be the origin of the 1699 word nigmenog. This probably gave rise to ning-nong, which appeared in 1832. Although it first appeared in England, it quickly spread to Australia and New Zealand.
At this point ning-nong split. In Australia and NZ it became 'nong', and was used to mean a fool or a incompetent person. In the UK it came to be pronounced 'nig-nog', and was used to mean a new or unskilled recruit, or a foolish person.
But in 1959 English author Marshall Pugh used it to refer to a black (or dark-skinned) person, and since then this has become the most widely recognized usage. This change in usage was probably influenced by the word 'nigger' which had long ago picked up the same negative connotations that nig nog now has. It is very much derogatory, and should not be used.
Thanks to Wertperch for:
http://www.sterlingtimes.org/memorable_images51.htm
-- The Oxford English Dictionary was used extensively in researching this writeup.