Because she was complicant in the theft of his blue meth formula along with Todd and planned to distribute it -- or rather, was distributing it -- as far away as Europe. Walt was content to let Lydia and the Aryans take over the operation, but was comfortable knowing that their purity couldn't even crack 70%. When he found out blue was back on the street, he put two and two together that the Aryans must be either using Jesse or partnering with Jesse. That's when, the next morning, he purchases the machine gun and retrieves the ricin, only to crash Lydia and Todd's meeting in the very next scene.
Stealing's Walt's signature formula is a big no-no in Walt's book, and in his mind, she had to die.
Besides, Walt had already intended to kill her in season 5A twice: once when he thought she bugged a barrel of methylamine, and again (with the ricin no less) when he was planning the "early retirement" of all of Mike's guys in prison. Walt however changes his mind when she brings up the opportunity of exporting the blue meth to the Czech Republic (Episode 5A8 "Gliding Over All).
And of course, for the omniscient audience, the death made even more sense: 1) Todd's guys threaten Skylar and the family in "Granite State," going as far to never mention her knowledge of Lydia (when they met at the car wash earlier in 5B "Blood Money"). 2) Lydia's connections with the Neo-Nazis 3) Her betrayal of "Decklan" to help the Neo-Nazi's take over the Southwest meth trade 4) Her hiring of a hitman to kill Mike in 5A and lastly 5 ) how she uses sex appeal to control Todd in a creepy way.
So to us, it makes perfect sense, but it still makes sense only to Walt's single perspective as well.
I believe a lot of what fueled Walt's decision to kill Lydia were the emotions of anger and jealousy over Lydia having never been caught, but that's just my opinion of course.
Did they ever make a point to show that Walt intentionally gave Todd a substandard recipe when he quit? Not until the scene in the finale with Badger and Skinny Pete did I get the impression that it would have bothered him that the pure stuff was still being made. And, for that matter, I got the impression that it wasn't so much that it was being made that bothered him, but rather, that he knew the only possible way it could have been made was by Jesse. He learned from Lydia's visit to the car wash several episodes back that Todd wasn't pulling his weight. I don't remember then getting the impression that he purposefully made sure of that, just that he wanted nothing to do with the business anymore.
The first time he wanted to kill her, it was actually Mike's idea that he just went along with, and it turned out they were wrong about her then. And the second time, it was along with a bunch of guys that he wanted/needed dead so they wouldn't rat on him. He's not exactly in a position to care about potential rats anymore, seeing as how he is the most wanted man in America and about to die anyway.
It just seems like he doesn't really have much reason for wanting her dead.
All good points. But I think you're underestimating how pissed Walt gets when you mess with his baby blue. Walt never intentionally gave Todd a bad formula. He just knew that Todd would never be able to recreate the blue without much, much more practice with Walt present, a la Jesse. Jesse could not achieve blue level production levels on his own until at some point in season 3, and that was after many, many, many cooks under Walt's guidance. And remember how much Walt freaked out when he found out Jesse was capable of making it on his own? Or how he got Gale fired after he realized he would soon be able to learn how to cook it blue on his own?
The decision to kill Lydia was most likely made the night before this meeting, after Walt realized that the Aryans must be using Jesse to cook for them. He then assumes that they have connections to Lydia who is then distributing for them.
Walt's entire run in the finale relied heavily on luck, kismet, good fortune, whatever. The keys falling from "the sky" after Walt prays to God to let him return to ABQ sort of suggest that in the episode's cold open.
He assumes Lydia will be at the coffee shop at 10am on Tuesday. He then assumes, that if she is there, and is distributing the blue for the Aryans, this is his one chance to off her with the ricin. So he puts the tampered stivia packet there just in case. When she actually does show up and meets with Todd, his suspicions have proven correct. Had Todd not shown, Walt very easily could have walked up to that table, and taken the stivia packet before she had a chance to use it.
Again, pure luck played into Walt's favor in this scene, just as it did in the final scene, just as it had in him eluding the authorities throughout the episode despite walking around in plane sight, or just as it had in magically finding the car keys in the beginning.
That's my take, anyway.