A lot (most) of the humour is provided by Lord Goring and his interactions with various other characters. His lighthearted flirtation with Mabel Chiltern is amusing, as is every scene in which his father is haranguing him over his lack of either a career or a wife. This humour provides a lighter mood, contrasting with the seriousness of the blackmail plot. Despite his father's low opinion of him however, Arthur is not stupid. Rather, he fulfills the role of a Shakespearean "fool" of whom Isaac Asimov said in the Guide To Shakespeare, "That, of course, is the great secret of the successful fool- that he is no fool at all." Lord Goring's conversation is frequently frivolous and trivial, but in spite of this he is essentially a teller of truths. He makes pointed and, though couched in cynical terms, often accurate observations about their society. In addition, despite his reputation for being shallow, Arthur's advice to both of his friends is always solid and sensible, recommending that they be frank and honest with each other. It is also Lord Goring who manages to outmaneuver Mrs. Cheveley and save the day.
Mrs. Cheveley gains the upper hand with Robert because she knows that public exposure of his past act will destroy his career. If it did, in one way that would be justice, as Robert would finally be brought to account for a crime he got away with when he was a young man. On the other hand, should a man's entire life be destroyed over a mistake in judgement made so many years before? One of the purposes of punishment is to hold a person to account for the wrong they have done. Sir Robert has done that to himself, and made restitution for his ill-gotten gains at least two times over. In a sense, he has punished himself. Another purpose for punishment is to try to deter the subject from ever engaging in the crime again. There is no danger of that in this case; Robert has lived a blameless and honourable life in the ensuing twenty years.
Arthur points out to his friend that his peers will show no sympathy simply because they themselves are morally compromised. Rather, they will be even more merciless in punishing his disgrace because it will allow them to appear more honourable in contrast, and to signal their virtue by the strength of their outrage. Given the many examples we have recently seen of Twitter mobs attempting to destroy people for innocuous comments, or past failings however minor, it is hard to argue that Lord Goring's assessment of human nature was incorrect, or that it has changed for the better since then.
So those are my thoughts on Oscar Wilde's play An Ideal Husband, which I definitely recommend. It can be enjoyed for its humour and clever writing, its often piercing insights into human nature, and for the questions about honour and morality which it poses. Definitely worth a read- or watch, as the case may be.
-Oscar Wilde, An Ideal Husband