Now that the war against the Night King is over, Game of Thrones is turning its attention back to the main event: the war for the Iron Throne. To most characters, there are only two real, legitimate options for the throne: Cersei Lannister, who's taken it by force and by virtue of her proximity to the Baratheon reign, and Daenerys Targaryen, who's attempting to take back the throne her family held for centuries. A select few, however, know that there's technically a third option: Jon Snow, who's actually Aegon Targaryen, a legitimate Targaryen heir. For a long time, only a few characters knew the truth, but now the word is spreading. In the season's fourth episode, Jon finally tells the truth to his Stark "siblings," and Sansa immediately tells someone unexpected: Tyrion Lannister, her sort-of-ex-husband.
It's a somewhat surprising move, since just one episode earlier, Sansa points out Tyrion's loyalty to Dany above any other claimants. Sansa's no fool, though, and she's proven to be a shrewd diplomat and political maneuverer. The timing of her reveal to Tyrion is quite telling; it comes right on the heels of Dany and Jon's departure for King's Landing, and Sansa has just realised that part of Tyrion's unshakeable loyalty to Dany is based in fear. He all but admits that he fears Dany, but also believes she could do some good, and that's when Sansa asks him, "What if there were someone else? Someone better?"
Tyrion, of course, promptly shares the reveal with Varys, and the men ponder the possibilities, including the fact that Jon is more popular with more groups of potential subjects than Dany is. This is, quite possibly, exactly what Sansa hoped for when she told Tyrion the truth about Jon. It's been pretty clear that Sansa doesn't like or agree with Dany, and that she believes Jon is endangering the North by bending the knee to the Targaryen queen. Now that she knows he actually has the better claim — and that he's ignoring that claim in favour of continuing to support Dany — she's even more frustrated.
By leaking the news about Jon's parentage to someone who already is starting to have sneaking doubts, Sansa is able to throw a wrench in the works and try to steer the coming events to an outcome more favourable to the interests of the North, and she can do it without actually having to do any dirty or treasonous work herself. After all, she learned from some of the shrewdest manipulators in Westeros: the Lannisters, the Tyrells, and Petyr Baelish. It's no surprise that she's picked up a thing or two about pulling the strings.