The story
Literally, the term refers to someone who is outdoors when the weather is cold coming indoors to a warm place. The idiomatic senses were popularized by the title of the novel The Spy Who Came in from the Cold (1963) by the British author John le Carré (1931–2020); “the Cold” is a pun on the Cold War, during which the novel is set.
Etymology from Wiktionary, CC BY-SA 4.0.