The Rightful Heir to the Iron Throne May Not Be Who You Think
Now that the Wall has come down on Game of Thrones, the question of who will sit the Iron Throne seems trivial by comparison. However, the Great War, as Jon has dubbed it, will presumably come to an end, and the matter of rebuilding the Seven Kingdoms after the dead are defeated is sure to play a role in the final six episodes. So the question of who is the rightful heir to the Iron Throne must be asked, and the answer isn't as simple as Bran's season finale proclamation of Jon's true heritage might suggest.
Even in Westeros, the line of succession seems to matter. When a dynasty is unseated, the only way for them to reclaim their power is through force or internal support from people in power. Technically, that means Daenerys and Jon's Targaryen blood doesn't automatically mean Cersei should hand the throne over to either of them. Like it or not, the Targaryens were defeated in Robert's Rebellion, and Robert was named king. The moment he took the throne, the Baratheon family became the ruling dynasty in Westeros. Sadly, they haven't fared well since then. With their line almost entirely gone, the matter of succession has become muddled to say the least, but it's not impossible to untangle. Let's take a look at the people with the strongest claim to the Iron Throne who are still on the playing field.
Gendry is the last living member of Robert's immediate family. Unbeknownst to Robert, he produced no true heirs with Cersei, but since Ned's attempt to expose the incestuous parentage of Joffrey, Myrcella, and Tommen failed, in the eyes of the Seven Kingdoms, they were next in the line of succession after Robert's death. With all three of Cersei's children dead, having produced no heirs, Gendry's claim could be strong if he had anyone with clout championing him.
With both of his uncles and his cousin Shireen dead, Gendry is the last of the Baratheon line. However, he's also a bastard. That means he would have to be legitimized in order to claim the throne, and he doesn't seem to be interested in ruling. Much like his father, Gendry appears to be more of a fighter than a king, and even if he was legitimized, he probably wouldn't pursue the Iron Throne.
In the season seven finale, Bran says, "He's never been a bastard. He's the heir to the Iron Throne." It's an amazing moment, but Jon's path to ruling the Seven Kingdoms isn't that simple. He is the true-born son of Rhaegar Targaryen and Lyanna Stark, so he would be the next Targaryen in line if Robert's Rebellion had never happened. Just because the legitimate Baratheons are all dead, doesn't mean Westeros has to default back to the Targaryens.
However, Jon could take the throne by force, or he could simply win the favor of the people. The Targaryen name is associated with fear after the Mad King's reign, but with Jon positioned to be the hero in the coming war with the dead, the populous of Westeros may be more than happy to have Prince Rhaegar's son on the throne. The man was declared King in the North when he was still a bastard, so he certainly inspires devotion. Saving the entire realm would surely lead the people to forego the tricky nuances of succession and submit to a new Targaryen reign, led by Jon — err, Aegon — who is both a wolf and a dragon.
Daenerys believes she is the last living Targaryen, and that the Iron Throne is hers by rights. If her claim had ever been that simple, then she would have strolled into Westeros and taken the Iron Throne with no pushback from the Great Houses. But the Mother of Dragons knows deep down that claiming power is not as simple as telling people that she's a Targaryen. She knows her family lost the war, and when they did, they lost their dynasty. That's why Daenerys is waging a war to reclaim the Iron Throne in the name of the Targaryens.
What she doesn't know is that she's neither the last Targaryen nor the one with the best legal claim to the throne. Her nephew/lover, Jon, would come before her in the Targaryen line of succession, but that may not be an issue. She's still the one with a massive army and two dragons. If the Targaryens are going to reclaim the Throne, they're going to have to take it, and given Daenerys and Jon's current romantic situation, it may not matter which one of them has the strongest claim. Given the Targaryen practice of marrying their relatives, the last two Targaryens could rule together. Daenerys wants to break the wheel, after all, so why bother clinging to antiquated rules of succession? Maybe it's time for Westeros to have a king and queen of equal power.
Cersei is just a pretender to the throne, right? Not according to Reddit user webby131, who did the hard work of mapping the Baratheon bloodline back far enough to find that the only living relatives of Robert can be found in House Lannister. Now, since Tywin is dead, Jaime is technically the rightful heir to the Iron Throne. Remember, Tommen relieved Jaime of his status as a member of the Kingsguard before his death, which means Jaime can now inherit lands, marry, and do anything else he wants to do. The one thing he doesn't seem interested in is ruling the Iron Throne.
So, let's say Jaime ignores his claim, or is unaware of it. In that case, Tyrion, as the second son, would be in the next in the line of succession — well, he would be if he hadn't been convicted of killing his nephew, committed patricide, and joined forces with Daenerys as her Hand. That means that by default, Cersei is the rightful heir to the Iron Throne. She's not a pretender at all; the rules of succession point to her, as long as her brothers stay out of her way.
Of course, this is all based on one version of real world succession rules. Game of Thrones has never fully explained the rules of succession in Westeros, and it has been established in the show that many characters believed Robert was a usurper even after he became king. These people are devoted to the idea that the Targaryen line is the one and only true dynasty, and they would surely support Jon's claim. So, while Cersei may be within her rights to sit on the Iron Throne, there's no denying House Targaryen is destined to rise again. The real question is if Daenerys will be able to live with the knowledge that Jon has a better claim to the throne than she does, or if her newfound family member and lover will be seen as a threat to her power when the Great War ends.