The main plot of The Importance of Being Earnest concerns the obstacles to the romances of the four main characters Jack, Gwendolyn, Algernon, and Cecily. These are what form the "frame" of the play. This means that these obstacles, which are presented in the beginning of the play and are resolved at the end, contain, and, in a play like this, to some degree define everything that falls inside these two limits. The subplot concerns Miss Prism, whom we come to find misplaced Jack as a baby.
The way Wilde integrates the two plots is both transparent (meaning we can see it coming) and ingenious. It is not necessary to have the element of surprise, for, though not lacking in dramatic effect, this play is not a drama. It is a comedy, and a satirical, somewhat farcical one. Surprise can be funny, but the dramatic surprise of Miss Prism being the baby nurse (now a governess in that self-same grown-up baby's home) who lost the child Jack is too coincidental and unbelievable to work as drama. However, when sufficiently telegraphed to the audience ahead of time, and that audience being in possession of the facts of Jack's utterly happy childhood and adulthood and lack of ill-effects from his misplacement, the revelation of Miss Prism as the agent of Jack's estrangement from his birth family is funny rather than dramatic or tragic. Wilde knew this, and if Jack had been a neglected or unhappy child the abandonment would not have been funny. Miss Prism is also put in the light as very good-hearted, admirable (at least to Canon Chasuble), and a likable person. The audience is freed from any feelings of anger or outrage toward Miss Prism, and thus able to fully appreciate the joke.
Since the main obstacle to Jack's marriage is his lack of known antecedents (and Gwendolyn's attachment to the name of Earnest) the revelation that Jack was really part of Lady Bracknell's family (as evidenced by the bag in which Miss Prism put Jack as a baby being produced) dissolves all obstacles. Miss Prism is forgiven, Jack is welcomed into a family and allowed to marry, and Algernon's difficulties with Jack's ward are dissolved. The one revelation -- that of Miss Prism as the wayward baby nurse -- resolves all the open elements of the plot. As a light-hearted comedy, especially one with a strong satirical streak running through it (satire directed toward both the dramatic form of romantic comedy and the upper class people represented in them as characters), it is perfectly plotted. There are no loose ends, and, within the bounds of silly conventions set up by the play, everything makes sense. Even more importantly, everything is preposterous and, therefore, very funny.