And if R actually married Lyanna, then Jon would be legitimate.
Exactly. And if Jon is legitimate, then his claim to the Iron Throne would be stronger than Daenerys’s claim, because he would be the son of the son of King Aerys II Targaryen, “The Mad King”.