I'm going to copy/paste my old answer from this Movie.stackexchange question. I believed it back then and S08E02 only confirms my theory even more for myself after seeing Daenerys her reaction when Jon told her what Bran and Sam had told him.
I believe Tyrion knows about Jon's parents.
That is why he looks so confused. On one hand, he wants a next in line for Daenarys, on the other, he feels this is wrong, especially because they (Dany and Jon) don't know. Unlike Cersei and Jaime did.
Varys told him...
How does Varys know? In season 1, Varys visits Ned Stark a few times in his cell. On the last visit, Varys informs him that they will let him "take the black" and live out his days with his bastard son if he pleads guilty and asks for mercy.
Ned asks for one last favor and asks for ink and paper. In 7 season, it has never been revealed what was in that letter or to who it was written too.
He most likely wrote it for Jon or about Jon, so that he didn't take the truth with him to his grave.
Why would he risk this with Varys?
- Varys use to advise the Targaryen Mad King, so he was originally a Targaryen supporter.
- Jon is relatively safe at The Wall from the Lannisters claws if it gets out.
- Varys seems to be the only ally Ned has at that moment.
After 7 seasons, that letter is forgotten by most viewers so that it will have enough shock effect when it is revealed.
Varys trusts Tyrion, so it would not be such a surprise that he told him.
But why would they keep it a secret?
They have no proof other than Ned Starks letter.
They have no reason to reveal this to either Dany or Jon, it could only bring internal disputes.
If Daenerys has to hear this truth from a crippled boy with visions and a drop out maester who is in the Night's Watch, she will be skeptical about it, like she is about everything without proof.
But if 2 of her trusted advisors confirm this news, she will be more open to the truth.
Varys was also the Spider when serving the Mad King, he most likely knew the truth behind Rheagar and Lyanna's relationship and might even know about their secret wedding.
Let Howland Reed visit Wintefell at that same time and confirm that Ned came out of that tower with baby Jon, and all the North will believe it too, because everyone knows the story of how Ned killed Ser Arthur Dayne with Howland Reed at his side.
The big "Jon is a Targaryen" reveal must be well supported, not just to convince Dany, but everyone who is convinced before it is revealed is one less doubter and easier to explain why they will all accept this story as truth.