The story
From the standard accounting practice of using red ink to denote negative values, especially a net loss. The first known written use of the phrase is from the "Wise-crack dictionary" (1926) by George H. Maines and Bruce Grant.http://www.phrases.org.uk/meanings/202000.html
Etymology from Wiktionary, CC BY-SA 4.0.