They go back to a series of articles Gary Gygax published in a
Diplomacy fanzine called
Thangorodrim in 1969 and 1970. Gygax seems to have been extrapolating from Smaug in
The Hobbit who is red and breathes fire. From there the colour-coded dragons made their way into
Chainmail and then D&D. Excerpt from Jon Peterson's
Playing at the World Vol II:
The cover of the second Thangorodrim depicted a dragon with the caption “Gary Gygax, alias Smaug—yes, there are good worms, too!” Within, a Diplomacy press release related to Smaug entitled “Red Dragon Remains Raised” referred to the scholarship of one Professor S. K. Eltolereth, curator of the Rhovanion National Museum, who recently supervised the recovery of an enormous dragon corpse from Long Lake. While it offered no particular description of the quality of red dragons, the next issue of Thangorodrim contains a second part of a manuscript supposedly translated by Eltolereth detailing the qualities of the “Arctic Dragon,” or Draco Articus, a white beast whose primary weapon is a chilling breath. The editor of Thangorodrim then revealed in an aside that this professor is, in fact, a pen name for Gygax, who will contribute further dragon lore to subsequent issues. The November 1969 issue describes Draco Nigrus, the “Black or Spitting Dragon,” a smaller dragon who spews streams of a “potent caustic enzyme” when angry. This was followed by an installment on the Green Dragon (Draco Chlorinum), enemy of the Mountain Giants, which breathes clouds of chlorine gas, is highly intelligent and hoards jade; a subsequent issue (July 1970) tells of the Draco Electricus, the Blue Dragon, which attacks enemies with lightning and is hunted by trolls for its blue hide. The final installment details the “Mottled or Purple Worm,” which the entry concedes is “not a true dragon,” being wingless and without a breath weapon, yet it has a “venomous sting in the tip of its tail.”
By the end of 1970, of course, the publication of Chainmail was imminent, and its “Fantasy Supplement” has a great deal to say on the subject of dragons. The system description deals with the Red Dragon (Draco Conflagratio or Draco Horribilis, it specifies), which breathes fire in a truncated cone in front of it that is almost certain to kill any opponent other than a Wizard or another dragon. The conclusion of the entry notes, however, that “other kinds of Dragons can be introduced into games, if a little imagination is used” and goes on to describe the white, black, blue, and green dragons, as well as the purple dragon (not here described as a “Worm”), and even notes that the basilisk and cockatrice should be considered as branches of the dragon family.