What makes you think Section 31 is being rational in how it determines what is or is not in the Federation's best interests?
Self-preservation? Self image? Granted, those are not necessarily "rational" but after all they "...are on the same team, they believe in the same principles that every other Federation citizen holds dear...
" (Sloan. DS9 : "Inquisition").
And on second thought, just because something is government sanctioned like the Tal Shiar, Obsidian Order or any real intelligence force today, that doesn’t make their actions "legal" or "moral". If 1/3 of all their cases were to become public (and evidence of them could be retrieve!) I wonder how many would stick in a civilian court of law. Like the case of Alexander Litvinenko or the Gestapo.
Ironically, I find S31 refreshingly “honest”. They are above the law, they admit it and they act like it. They don’t give you the tiresome “this is for the good of the State or Empire speach and then they shoot you in the head, they just do it”.
As an organization, they have their mission and vision very clear, they think ahead or at least plan for the future and they move with the changes. As such, they existed for at least 2 centuries, assuming Michael A. Martin and Andy Mangels story gets followed by TPTB (BTW, thanks for the data Sci) so, my money is still on them for at least several decades more in Star Trek 24 century universe.