Spoilers ahead for Game of Thrones Season 8, Episode 5. The Spider's scheming was bound to catch up to him eventually, and on the May 12 episode, "The Bells," Dany killed Varys on Game of Thrones. Well, the Dragon Queen didn't so much execute him as have Drogon burn the eunuch to a crisp. However, the Master of Whispers knew it was coming, taking off his jewelry and burning a suspicious letter before Grey Worm and his soldiers captured him. From there, Varys was taken down to the beach, where he was turned into a human torch.
Audiences saw this foreshadowed in Episode 4, "The Last of the Starks," when Tyrion told Varys who Jon's parents really were. After the fact, the Spider pointed out that Jon has a better claim to the throne. But even though the Lannister said that Jon doesn't want to be King of the Seven Kingdoms, it may not be up to him. As Varys said, "I'm not sure it matters what he wants. The fact is, people are drawn to him. Wildings, Northmen. He's a war hero."
And since Varys became convinced that the former bastard had a more legitimate claim to the Iron Throne, he began sending whispers to his little birds about Jon. The only problem, however, is that he still worked for Dany.
That's likely also why he was writing that letter at the beginning of the episode — informing the rest of Westeros that Aegon Targaryen (read: our good ol' Warden of the North, Jon Snow) is the true heir. Naturally, Dany became upset. As she warned Varys, she'd "burn him alive" if he ever betrayed her, and she was true to her word.
However, many have been calling Dany the Mad Queen, due to her volatile behavior, which was reminiscent of her father, the Mad King. And she was certainly having a tough go of it at the start of Episode 5, having just lost both Rhaegal and Missandei. As a result, she wasn't feeling particularly inclined to be merciful. Plus, there's the fact that Jon's attraction to Dany was cooling considerably (she is his aunt, after all).
So while her actions may seem uncharacteristic, the Dragon Queen was simply following through on a promise she made. We've also seen her do similar things before, banishing Ser Jorah when she discovered he was originally sent to spy on her. However, it's still a particularly brutal scene to watch Varys's ad hoc trial and execution. "Lord Varys, I, Daenerys of House Targaryen, First of My Name, Breaker of Chains and Mother of Dragons, sentence you to die," she tells her Master of Whispers. Then, of course, came those fateful words Missandei had uttered just an episode before: "Dracarys." And just like that, Varys was lit up like a Christmas tree.
But while Varys deserved to die for treason, he was simply looking out for the realm. In fact, he gave the queen great advice in Episode 4, pointing out that if she attacked King's Landing, thousands of innocents would die. And that's exactly what happened.
However, some fans thought that Varys saw it coming. After all, he's long taken advantage of his "little birds," manipulating people when it pleased him. And as Melisandre prophesied back in Season 7, they would both die in "this strange country" — and die they did. So although the eunuch met his end in Episode 5, it was bound to happen sometime this season. And if it wasn't Dany who killed him, it would have been someone else.