There are a few ways to answer this question. In Oscar Wilde's The Importance of Being Earnestthe character of Algernon Moncrief is by no means the main character, but is certainly the one who gets most of the attention. This is because Algernon represents the epitome of the Victorian dandy: The young bachelor who lives above his means, has a title to boast (or comes from a titled family), does nothing but enjoy himself, and lives like a sybarite.
All these attributes constitute the basic canon of Wilde's philosophy of life: Experience sensations, worry about nothing, live above your means, be mischievous. In not so many words, Wilde uses Algernon as his own mouthpiece as he has done in the past with the dandy characters of his stories.
It is Algernon who questions the gist behind morality, good behavior, ethical behavior, and all that is considered "prudish" in Victorian society. He unveils Jack's double life, is insubordinate, loves getting in trouble and has no worries in life but eating and drinking- like Wilde himself.
Taking all this into consideration, it is safe to argue that Algernon is indeed the "Ernest" that Jack pretended to visit in London during his escapades. Hence, Algernon is not only Jack's alter ego, but he is also his equal: The part of Jack that loves to play with fire.
In bringing Algernon to the mix Wilde is adding himself as part of his equation. In such equation, the part that Algernon plays is meant to disturb and disrupt any fantasy of normality in life. Algernon is designed to open the eyes of the characters, and bring all the attention onto himself. That is why he is so beloved.