The purpose of comedy is to elicit one's sense of humor by adding triviality to the treatment of serious topics.
Like your question accurately states, in The Importance of Being Earnest, the otherwise serious topics of social separation, love, double lives courtship and marriage are mocked in the paradoxical situations where the serious topics are used:
- the women want to marry a man for the sake of his first name
- the need to find "family" for Jack in order to be accepted
- Algernon's careless treatment of his family
- Jack's and Algernon's secret dealings
However, the play also uses comedy to critique by filtering the mockery through specific channels of analysis. These filters include the social, ethical and moral aspect of the situations where the characters are placed
- social- are the British higher classes worth their salt? Are they worth the respect and deference that they are given? Do Wilde's upper-crust characters accurately represent real life examples?
- ethical- do the condescending British upper classes deserve to look down on the lower classes? Aside from privilege, why would Lady Bracknell feel the need to look down on Jack? Is there something other than mere snobbery in her behavior?
- moral - do the moralistic British upper classes set any proper example given their powerful upper hand? Is there any truth in Algernon's paradoxical statement stating that the lower classes are meant to set an example for the upper classes?
The situations that the upper class characters are put through in the play, although comical, do invite the audience to wonder to what extent art is imitating life, or vice versa. Adding the social, ethical, and moral angle to the mockery transforms it from mere empty humor to a great opportunity for further analysis.