Spoilers ahead — don't read if you haven't seen the season-four finale of Game of Thrones.
Considering how little we've seen of Stannis Baratheon lately, his sudden appearance beyond the Wall might be as shocking to viewers as it is to Mance Rayder — how did he get there? What is he doing? And what does it mean for Westeros?
Stannis has been gnashing his teeth over his birthright ever since his big brother Robert died in that drinking-and-boar-hunting expedition, thanks to a letter Ned Stark sent, letting him know that the princes Joffrey and Tommen were actually twincest bastards. (Stannis took the chain-letter approach and sent the news to "every lord from the Arbor to the Wall.") Over and over, we've heard Stannis say, "The Iron Throne is mine, by right." But inheriting it and earning it are two different things, as he learned very quickly. Even his own younger brother Renly ignored the "bloody line of succession" because he didn't think Stannis would make for a very good king. "What's best for the kingdoms? What's best for the people we rule? He inspires no love or loyalty. He's not a king." (Plus, as Loras pointed out, "Stannis has the personality of a lobster," which is why he wasn't winning the popularity contest, despite his superior battle résumé.)
Stannis inspires loyalty mainly in just two key people: Davos, the Onion Knight, and Melisandre, the red priestess. Through Melisandre's magic, he knocks out Renly as competition and snags most of his troops, which made him a serious threat at the Battle of Blackwater. But then he was outwitted by Tyrion Lannister, and subsequently lost most of what he had just gained — his 100,000 men dwindled to 4,000; his 200 ships went down to 32.
Despite Stannis sitting around feeling depressed and defeated throughout most of season three, Melisandre refuses to give up on him or, at least, on her assignment. (Her meeting with Thoros of Myr reveals that perhaps each red priest/priestess was assigned a different ruler to convert.) Regardless of what she actually believes, she tells everyone that Stannis is the fulfillment of a prophecy about a warrior who would "draw a burning sword from the fire." She doesn't quite say Stannis is the resurrected warrior Azor Ahai, but that's what she means when she calls him "the Lord's Chosen." She shares her vision in the flames and tells him, "You are the son of fire. You are the warrior of the light. You will be king." (Stannis later describes the vision to Davos as a "great battle in the snow," which might be why he's more willing to head North than usual.)
As much as Melisandre can encourage Stannis (and it's debatable how much her blood magic contributes to the deaths of Joffrey and Robb Stark, or how much of her magic is parlor tricks), she's not able to guide him all that much as far as strategy. This is where Davos steps in. He's the one who realizes that Melisandre's fire god R'Hllor and her "visions and prophecies" won't win a war or provide them with any ships or soldiers, even if the other kings are dying like flies. Davos is the one who rallies other houses (Peasebury, Musgood) to Stannis's cause. And to augment the troops from Westeros, Davos is the one who suggests looking east to hire a company of sellswords, such as the 10,000-strong Golden Company. But how to hire anyone when they don't have the gold? Davos then comes up with the idea to get a loan, and helps procure it when Stannis is at first denied.
If King's Landing were not already bankrupt from wars, weddings, and tournaments, this gambit might not have worked. But thanks to the crown's debt and lack of income, the current regime looked less like a sure bet, despite all the Lannister talk about paying their debts. Just like the Lannisters, the Iron Bank of Braavos also has a motto — "The Iron Bank will have its due." If you don't pay back the money you owe, it will back your rival instead.
Loan in hand, Stannis doesn't head to King's Landing and try to declare himself king — but instead acts as a real Protector of the Realm should. No other ruler in Westeros paid any heed to the ravens from the Wall, warning that the White Walkers had risen again, something Melisandre has been warning them about: "For the night is dark, and full of terrors." Hidden sometimes in the background of her magic mumbo-jumbo were references to the Long Night and the dead rising in the North. So when Davos shares the news from the Wall, she tells Stannis, "This War of Five Kings means nothing. The true war lies to the North. Death marches on the Wall, and only you can stop it." It just took Stannis all season long to get there, only to arrive in time to find Mance Rayder's army instead.