After learning from Sansa how wicked Joffrey was, Olenna knew she had to kill him because if he married Margaery and hurt her, then Loras would kill him. To avert a future crisis, she poisoned the King.