That's because taking out Irene would have had consequences. It's not merely that others having that information would hurt them, it's that them not having it (even if no one else did) would hurt them. So Mycroft had no choice but to deal with Irene to get the password lest the information be lost forever. I should rewatch the episode to be sure though, but I remember they needed to get that information or they suffer.
Magnussen, however, there is no consequences to his demise as far as we can see. He had no evidence and, being dead, he can't spread the information that would hurt them to the appropriate parties. That's the difference, they absolutely needed the information Irene had, they don't with Magnussen. They just need him to shut up. And the best argument Mycroft could come up with is "He doesn't hurt us badly enough to warrant retaliation." It didn't seem implied that Magnussen does anything for them other than not make too much of a ruckus. Mycroft called him a necessary evil, but necessary to what? They should have explained that more, I think. As it stands, he's just a ridiculously powerful piece of shit. He goes out of his way to be a piece of shit and his only defense is "If you don't let me be a piece of shit to you, I'll tell X about Y". Well, the obvious reply to that is "Well, what if you can't tell anyone about anything?" To this, he has no response. Not just to Sherlock, but to Mary as well. When Mary had the gun on him, all he could think to do is appeal to her moral sensibilities of all things. He literally has no contingency plan if someone just has enough of his bullshit and takes him out. An the short glimpse of the post-magnussen world we have thus far, there doesn't seem to be any fall out. When Mycroft had that meeting about Sherlock's fate, the core of their argument for Sherlock's punishment was driven by the fact that he did something immoral ("Regrettably, my brother is a murderer.") than that they have cost the government itself anything, and Mycroft doesn't mention any bad thing happening. There was a theory that he kept Moriarty under cover and that's why Jim came back only after Magnussen was killed, but it's not like they knew about that.
So that's the thing about Magnussen. He is very scary and intimidating, sure, but he's not very intelligent outside of his memorization ability. He doesn't seem to realize that 'knowing' isn't enough, he has to convey that information to somewhere for it to be useful and that he is, in fact, mortal. So, he doesn't make any "In the event of my death" plans. And I can accept that. He has a massive hubris and he's in such a position of power that normal people can't hurt him. But mycroft? Just detain the guy under whatever pretense you want to make up. From there, whatever information he has, he won't be able to convey anywhere. Find the appledore vaults or don't, and the next step is equally simple. The only possibility I see that is presented to us is that...well, Mycroft made a tremendous miscalculation. He overestimated Magnussens abilities by far. But I just don't see Mycroft (atleast in this TV show) being the kind of guy that won't verify his hypothesis'. So even if he he didn't know, it's beyond me how he wouldn't find out by using a spy or whatever.