During the American Civil War, military prisons were rather frail and quickly put together, with wooden barriers being erected. A large number of prisoners had to be held, and the capacity had to be created in a hurry. This meant that there was always the fear of soldiers escaping the prison walls. The best way to avoid this problem was to draw a line around the wall on the inside and instruct the prisoners not to cross the line.
The prisons were guarded by men with shoot-to-kill orders in case anyone was found crossing the line.
That line came to be known as the deadline. If you crossed it, you were dead.

In the early 20th century, that word transitioned to be used in a metaphorical sense, especially in the publishing and news industry. Since news had to be sent into print by night so that the paper carried the story in the morning, there was intense pressure to post stories before a certain time after which the print run could not be changed. That time came to be known as the deadline.
And like that, the meaning of the word morphed to denote a time.