There's an ancient prophecy central to both the Game of Thrones TV show and the Song of Ice and Fire books that describes a last battle of good versus evil.
The prophecy stems from a battle that took place about 8,000 years before the events of Game of Thrones, during a previous White Walker invasion.
People in Westeros describe a "Last Hero" who will emerge in a final showdown, while people in Essos believe an ancient warrior named Azor Ahai, who once defeated the White Walkers, will return for a last battle. They call their version "The Prince Who Was Promised."
Both stories agree that White Walkers will return and attempt to usher in a long night, and a great warrior will rise up and save the day.
In Chapter 10 of A Clash of Kings, the prophecy is laid out like this:
There will come a day after a long summer when the stars bleed and the cold breath of darkness falls heavy on the world. In this dread hour a warrior shall draw from the fire a burning sword. And that sword shall be Lightbringer, the Red Sword of Heroes, and he who clasps it shall be Azor Ahai come again, and the darkness shall flee before him.
And in a special feature on the Blu-ray of Season 3 of Game of Thrones, Thoros of Myr describes the same Azor Ahai prophecy like this:
On one side is the Lord of Light — the heart of fire, the god of flame and shadow. Against him stands the Great Other, whose name may not be spoken: the lord of darkness, the soul of ice, the god of night and terror. According to prophecy, our champion will be reborn to wake dragons from stone and reforge the great sword Lightbringer that defeated the darkness those thousands of years ago. If the old tales are true, a terrible weapon forged with the lifeblood of a loving wife's heart. Part of me thinks man was well rid of it, but great power requires great sacrifice. That much, at least, the Lord of Light is clear on.
There are some clear details that stay consistent:
• A prince named Azor Ahai appeared at a moment of great darkness.
• He had a flaming sword called Lightbringer.
• The sword was forged in a loving wife’s blood.
• Azor Ahai then used that sword to defeat the "Great Other."
• Then a prophecy called "The Prince Who Was Promised" was written in high Valyrian.
• It says that Azor Ahai would one day return.
• He would be born from the line of House Targaryen.
• And he would once again wield Lightbringer to conquer the darkness.
The character most obsessed with "The Prince Who Was Promised" is Melisandre, the Red Witch.
And Melisandre eventually adds some more details to the Azor Ahai myth:
• He appears after a long summer, when the stars bleed and the cold breath of darkness falls heavy on the world.
• He shall be born again amidst smoke and salt.
• He shall wake dragons out of stone.
She then convinces Stannis Baratheon that he's the Prince Who Was Promised. His grandmother is a Targaryen, so the lineage checks out. The rest of the details don't line up so well, though.
He gets a flaming sword and he names it Lightbringer. Then he spends most of Game of Thrones pretty convinced he's Azor Ahai.
Except, whoops, he wasn't. And then he dies (probably...it happened off camera, and with this show, who the heck knows). Sorry, Stannis, better luck next time.
We also learned at Dragonstone this season that apparently in High Valryian, "prince" is a gender-neutral term. Which means Dany could fulfill the prophecy.
Dany makes a little more sense as the Prince(ss) Who Was Promised.
• She's definitely got Targaryen lineage.
• And she was "born again amidst smoke and salt" in the Dothraki Sea.
• And she has literally woken "dragons out of stone."
There's also the possibility that Jon Snow is Azor Ahai. Aside from the whole resurrection thing, there are more than a few similarities between the Prince Who Was Promised and Jon.