On the subject of the morality of lying and secrets, I really like the utilitarian approach, that one must search for the greatest happiness for the greatest amount of people.
In your example, telling the husband about the affair could... nah. It most likely will go against that goal. At least on the short term.
The wife has two choices: Keeping the secret and bearing the guilt, but keeping her husband happy and content, or telling him, which will diminish his happiness and might or might not ease her conscience. It might cause a breakup with everybody being miserable.
That would suggest that keeping the secret is the moral choice. But...
A relationship works best if both are happy in it. She isn't, so keeping the secret might just delay the inevitable. The husband might forgive her, and the relationship could end up stronger than before. Or the breakup, that at first made everyone miserable, allows both to find partners that are better suited, which ends up causing the greatest amount of happiness for not only two, but four people. The chances for that are marginal though.
As you see, both lying and being truthful can lead to good or bad.
I don't think it is immoral to keep secrets. I think it is not even immoral to lie, unless it is done with intent to harm. And, I don't think that telling the truth is by default morally right.
But what do all the bad endings have in common? Weakness.
The reason we lie is that we are weak. Either the liar or the belied is not able to handle the truth, or we just don't trust people to deal with the truth in a manner that aims for the greatest benefit of all involved. This weakness is the cause of lies, and the nature of the evil that we falsely deem to be within the act of lying itself.
If the Bible speaks of the Father of Lies, that is how I as atheist would picture him: Our weakness, our distrust, and our lack of benevolence in the face of uncomfortable truths.