Warning: Major Game Of Thrones finale spoilers follow.
No one really believed that Daenerys would make it out of Game of Thrones alive after she burnt King's Landing to a crisp. But fans mostly expected it to be Arya who would kill her. Instead, Jon Snow killed Daenerys during the Game of Thrones finale. It was a surprising moment when Jon sneak-attacked her during a kiss, but it makes sense why he did what he did.
At first, it seemed like Jon was going to stand by Dany, even if he didn't like the way she ended the war. He told Tyrion that he couldn't justify what she did, but that she was his queen. Tyrion, who was imprisoned for freeing his brother and committing treason, begged Jon to do what was "right" and kill Dany for the sake of the people. Jon seemed conflicted at the end of their conversation, but he still seemed in support of Dany. Yet it was this conversation with Tyrion plus his conversation right afterwards with Dany that seemed to solidify Jon's decision to murder her.
Tyrion tried a number of tactics to get Jon to see who Dany really was. He said Dany would try to kill Jon, but Jon didn't care. "That's her decision, she is the queen," Jon answered. Tyrion tried to explain that if Arya and Sansa didn't bend the knee, Dany would kill them too. Jon (delusionally) believed his sisters would obey the throne, whoever was on it. But Tyrion also tried to explain to Jon that Dany wasn't going to stop here. She planned to "liberate" the rest of Westeros, and she believed it to be the right thing. That seems to be what got Jon in the end.
When he spoke with Dany he asked her to forgive Tyrion but she would not. She also didn't really acknowledge the damage she'd done to even little children to earn the throne. But Jon seemed most upset when Dany claimed to know what was right for everyone. "How do you know it'll be good?" Jon asked of Dany's vision for Westeros. "Because I know what is good," Dany answered. Jon asked what about the people who had their own version of what "good" is? Dany replied that they would have no choice but to accept her version of good. Shortly after, Jon stabbed her.
It's one thing to destroy your enemies and lose some innocent lives in the process. Jon has led armies to their deaths before in a number of causes. But he has always been able to see the greater cost. He went to Dany looking for her to acknowledge that the cost of her getting the crown was a huge and terrible loss of life. But Dany didn't think it was. What she thought was justified, Jon could never justify. And she continued to be merciless all while thinking she was good. She said to Jon, "We can't hide behind small mercies," but "small mercies" is basically Jon Snow's middle name. He saves everyone he can, and those he can't he feels miserable about. Dany didn't feel that misery or that cost. She was just giddy that she'd won the throne she'd always heard about since she was a child. Her inability to see the flaws in how she took the throne seems to be what finally got to Jon in the end. If this is what she thought "good" was, he had to kill her for the greater good — the survival of the people of Westeros.
Correction: This post has been updated to reflect why Tyrion was imprisoned.