The term is thought to refer to the way in which young (and therefore inexperienced) apprentice printers were liable to get themselves covered in black ink as a result of their work.
The Oxford English Dictionary cites Moxon's Mechanick exercises; or, The doctrine of handy-works. Applied to the art of printing. The second volume (1683) as the earliest example of a text using the term in this context. According to Moxon:
The Press-man sometimes has a Week-Boy to Take Sheets, as they are Printed off the Tympan: These Boys do in a Printing-House, commonly black and Dawb themselves: whence the Workmen do Jocosely call them Devils; and sometimes Spirits, and sometimes Flies.
Similarly, Boswell's Life of Johnson (1791) quotes Dr Johnson on the same topic (II, 397):
He had married a printer's devil... J. Reynolds: ‘I thought a printer's devil was a creature with a black face and in rags.’ Johnson: ‘Yes, Sir. But I suppose, he had her face washed, and put clean clothes on her.’