After Sam Tarly told the young Stark about what he read in one of the maesters journals (um, to be fair, Gilly was the one who actually should be credited with learning about Jon's true identity, not Sam), Bran went on a mission to uncover the truth. Using his powers, Bran went back to the day Jon was born to Rhaegar Targaryen and Lyanna Stark , where he learned that the man he thought was his bastard brother was destined to rule, and that his real name is Aegon