Since Wilde's play "The Importance of Being Earnest," is a comedy, inversions and uses of irony run rampant throughout. Word play on the word "Earnest" is used along with the name "Ernest" which produces irony and puns at different times. For instance, Jack is not earnest when he pretends to be Earnest in the city but remains "Jack" in the country. The double entendre creates a fun mood while also presenting part of the author's theme and purpose--that is, to be truthful is the best decision.
Other role reversals seem to cause comedy like the fact that Algy criticizes Jack's desire to marry Gwendolen in Act I, but quickly changes his mind about it when he meets Cecily. Along those lines, Algy seems to be of a higher social status since his mother is a "Lady" but Cecily comes from the country and lives as a foster child to Jack who seems not to have any ancestry to claim. Social rank at that time was determined on old money and inheritance (or heritage). The twist comes when Jack learns that his real, first born name is Ernest and he doesn't have to be re-baptized in order to claim the name.
Wilde also satirizes the the English social structure in this late 19th century play by having many of the characters argue against Lady Bracknell who is a strict follower of social rules. Lady Bracknell represents that social structure, in fact. In the end, she is also caught by her own strict adherence to the rules when Jack refuses to permit Cecily to marry Algy. Luckily, misunderstandings are cleared up enough to permit a compromise and everyone receives what they desire.
One of the best scenes for irony happens in Act I surrounding cucumber sandwiches!
I have no doubt about that, dear Algy. The Divorce Court was specially invented for people whose
memories are so curiously constituted.
Oh! there is no use speculating on that subject. Divorces are made in Heaven—[JACK puts out his
hand to take a sandwich. ALGERNON at once interferes.] Please don't touch the cucumbersandwiches. They are ordered specially for Aunt Augusta. [Takes one and eats it.]
Well, you have been eating them all the time.
That is quite a different matter. She is my aunt. [Takes plate from below.] Have some bread and
butter. The bread and butter is for Gwendolen. Gwendolen is devoted to bread and butter.
[Advancing to table and helping himself.] And very good bread and butter it is, too.
Well, my dear fellow, you need not eat as if you were going to eat it all. You behave as if you were
married to her already. You are not married to her already, and I don't think you ever will be.
Algy tells Jack not to eat the sandwiches, but then he eats them all himself and there is nothing for Lady Bracknell when she finally comes. Taking into account what Lady Bracknell represents, the whole scene seems better as that inversion, irony and hypocrisy join together to create a wonderful comedic effect.