There are any number of puns in the text that could have served as the title; the actual importance of the word "earnest" and the name "Ernest" are more to do with the motivations and actions of the characters. For example, Jack's friend Algie calls the same concept "Bunburying," after his fictional friend Bunbury who is often ill, allowing him an excuse to avoid events and people.
Lady Bracknell. It is very strange. This Mr. Bunbury seems to suffer from curiously bad health.
Algernon. Yes; poor Bunbury is a dreadful invalid.
(Wilde, The Importance of Being Earnest, gutenberg.org)
Algie's comment that Bunbury is "a dreadful invalid" is a pun, as it states both that Bunbury is commonly sick, and that he is "invalid," that is, not valid. The title could have been A Dreadful Invalid, and worked on similar levels, but it would have lost the direct meaning of the actual title, as well as the final line of the play.