I reflexively put a confidentiality clause in every settlement agreement. I am benefiting my client (which would rather not have evidence of payment be used as proof of fault as opposed to compromise) and the confidentiality clause plays an important role. It doesn't really hurt the other side, who is, I would think, mostly interested in getting compensated.
There is real public benefit when more information is in the public though. To take settlements, for instance - if I knew what the going rate is for settlements under X, Y, and Z circumstances because there were a database of the facts of every claim and the amount of the settlement, I'd have much more information. (This is also an argument in favor of the value to the public from trying more cases, which creates a written record of who is at fault and how much certain claims are worth, and the benefit of justice being done - and being seen to be done.)
And cases where there is private benefit but public harm sound a lot to me like market failure. If the market isn't going to reach the right result, courts ought to be more willing to step in.
I don't know what that would look like: when a non disclosure agreement or a protective agreement would be so burdensome, or the public interest so great, that it would be preemptively void, or that the consequences of violating it would be lessened. I do know that the rules should be clear enough that someone who is writing, or signing, a confidentiality agreement knows ahead of time what is and isn't covered, and that the parties know ahead of time whether and what sort of a breach would be permissible or punishable. Evidence of a crime? Hard to say that should be confidential (though I should note here attorney-client privilege is a whole different animal). What about evidence of noncriminal but awful conduct? How do you draw clear lines? And if you say a non-disclosure agreement that includes evidence of crimes is presumptively void, what if the would-be criminal defendant isn't charged, or if she or he isn't convicted? At that point, was there a violation of the NDA? Or do you say that you'll consider the public interest in determining penalties? That is cold comfort to somebody planning to come forward with evidence.