Bran goes into the past and learns from a vision that Jon is the true-born son of Rhaegar and Lyanna, and thus the true heir to the Iron Throne ahead of Daenerys. Jon and Daenerys make love.
Here's how: As you can see on this helpful diagram, Jon Snow's parents are Lyanna Stark and Rhaegar Targaryen. Rhaegar is Daenerys's brother, therefore.
One of Daenerys Targaryen's dragons, Drogon, approaches Jon calmly and allows the King in the North to pet him, seemingly recognizing him as a Targaryen.