As far as I know, the exact phrase was coined in Tim Burton's first Batman movie - it is the phrase uttered by Jack Nicholson's Joker before he kills. Dancing with the devil is a popular image, since the popular notion of pacts with the devil involved satanic masses, orgies, dancing etc... and such things always happened at night.