Roff Smith offers a history of the expression:
The phrase “red line” appears to be an adaptation of a much older metaphor – a “line drawn in the sand,” according to Ben Yagoda, a professor of English and journalism at the University of Delaware. One of the earliest recorded instances of anyone drawing a line in the sand took place in ancient Rome around 168 B.C., during a conflict that, curiously enough, involved Syria. A Roman envoy named Popillius was sent to tell King Antiochus IV to abort his attack on Alexandria. When Antiochus tried to play for time, Popillius drew a line in the sand around him and told him he had to decide what he was going to do before he crossed it. He acceded to the Roman demands.
But just how the venerable line in the sand came to be red is a little unclear.
One possibility is that a pundit borrowed the idea of the warning line on a gauge beyond which it is unsafe to rev up the machinery. Another explanation comes from the Battle of Balaclava on October 24, 1854, when the hopelessly outnumbered Sutherland Highlanders, the 93rd Highland Regiment, were told by their commander Sir Colin Campbell: “There is no retreat from here, men. You must die where you stand.” And so they stood firm, wearing their scarlet tunics and awaiting the charge. In his breathless account of the battle, London Times correspondent William Russell wrote that all that remained between the charging Russians and the British regiment’s base of operations was “a thin red streak tipped with steel.”
And now it’s a dick-measuring ribbon.