He was executed for treason, the main reason appears to be because he was conspiring outside of Dany's orders to inform everyone who Jon Snow is and that he has a better claim to the Iron Throne and so should sit on it instead of her.
Tyrion: Your Grace? There's something you need to know.
Daenerys: Someone has betrayed me.
Tyrion: Yes.
Daenerys: Jon Snow.
Tyrion: Varys.
[...]
Tyrion: If I have failed you, my queen, forgive me. Our intentions were good. We wanted what you want. A better world, all of us. Varys as much as anyone.
Daenerys: But it doesn't matter now.
Tyrion: No. It doesn't matter now.
Game of Thrones, Season 8 Episode 5, "The Bells"
Note though that Tyrion is aware that Varys would also try to assassinate Dany following their conversation in the previous episode so could have told her that off screen.
Varys: You know where my loyalty stands. You know I will never betray the realm.
Tyrion: What is the realm? A vast continent, home to millions of people, most of whom don't care who sits on the Iron Throne.
Varys: Millions of people, many of whom will die if the wrong person sits on that throne. We don't know their names, but they're just as real as you and I. They deserve to live. They deserve food for their children. I will act in their interest, no matter the personal cost.
Tyrion: So, what happens to her? Please. Don't.
Varys: I've spoken as honestly as I can. Each of us has a choice to make. I pray we choose wisely.
Game of Thrones, Season 8 Episode 4, "The Last of the Starks"
In "The Bells" it also appears that Varys is trying to poison her through the use of Martha bringing her food. However, Dany seems to be somewhat wise to an attempt to kill her and has locked herself away and isn't eating.
Varys: And? Nothing?
Martha: She won't eat.
Varys: We'll try again at supper.
Martha: I think they're watching me.
Varys: Who?
Martha: Her soldiers.
Varys: Of course they are. That's their job. What have I told you, Martha?
Martha: The greater the risk, the greater the reward.
Varys: Go on. They'll be missing you in the kitchen.
Game of Thrones, Season 8 Episode 5, "The Bells"
It’s also worth noting as mentioned in a comment that Dany made Varys promise to tell her to her face instead of going behind her back if he ever thought she was in the wrong. Whilst he has done that initially she ignored his advice and so now he’s going behind her back against her wishes so that probably plays a part in it too.