A great example is Iran-Contra, for nearly a year government officials including military leaders were brazenly violating US law. Several prominent members of the Regan Administration were indicted, tried, convicted, and subsequently pardoned by the then President H.W. Bush.
The initial leak didn't come from our government, but from a Lebanese magazine. So we had massive corruption at the highest level of government and military leadership, the checks and balances failed, and who knows how long it would have continued if an external source didn't blow the whistle.
Except that technically, no (US) laws were violated. The problem is that the government often engages in operations that are "legal", but which would not look good politically if the public were aware of it (like say, selling drugs in one country, to fund/supply rebels in another). It's not technically illegal (within the US) for the US government to use CIA operatives to sell drugs or provide guns (or assassinate people) in other countries. But it's bad politically for those kinds of operations to become public knowledge.
Where the illegality often comes about is that the need to not allow public knowledge (which btw usually has more to do with not **** off or embarrassing foreign governments than our own citizens) often leads various people in the know to lie about the operations. Which then results in them going to jail. And sometimes, they go to jail even though what they did was completely legal and authorized by their chain of command (leading to the president), but solely to protect that chain (and president) from the political fallout of having ordered something that the public might not like. Sad fact is that not all secret missions involve killing OBL and can be publicly declared after the fact. Most are no more illegal (legality is a gray area when it comes to executive operations outside the US btw) than that operation, but not so publicly acceptable.
Doesn't mean that there aren't cases of actual illegality outside the bounds of what was authorized, but a good percentage of the time the operations *were* authorized (and thus legal), but they don't want anyone to know it was authorized for numerous political reasons, so someone has to take the fall by claiming it wasn't, and he violated the law anyway. Which was precisely what Oliver North did in the aforementioned Iran Contra deal.
What's somewhat interesting in all the various scandals surrounding the Obama administration is that no one is coming forward and taking the blame. Which only makes these sorts of things worse in the long run. You have to either say "we authorized this" and take the political heat for doing something unpopular, or you must have a fall guy who'll say "It wasn't authorized, and I broke the law". This administration is trying to thread the needle between those, and I'm not sure that's going to work.