Comedy through the history of dramatic art has always served a social function--to reveal human imperfections and to chasten those whose self-interests violate the moral code of the society they represent. Even though the ancient texts that define and describe Comedy have been lost (unlike Tragedy) it is clear from the surviving texts such as Lystrata and the Roman comedies of Plautus and Terence that the laughing was a public condemnation of the human imperfections being depicted. In the Restoration the comedic writers were directly involved in returning English society to a sane, moral balance. In modern times, comedic writers such as Neil Simon have the same moral purpose--to expose excesses and unprincipled behavior.
First, as many thousands of playwrights have written comedies over a period of approximately 2500 years in cultures as diverse as Japan, Greece, India, Britain, France, and the United States, one cannot identify a single, uniform moral purpose in their works. Instead, comic playwrights take a wide range of moral stances or none at all. Second, although some comic playwrights such as Shaw have explained their moral purposes in prefaces or manifestos, for many playwrights all that remains is the plays themselves, and thus we have only minimal evidence of what the playwright might have had in mind while writing.
Although many comedies are written purely as entertainment, and the playwrights may have had little in mind other than making money through writing, many comedies tend to be conservative, supporting an existing social and moral order by making fun of those who diverge from its norms. Aristophanes, for example, represents the traditional aristocracy of Athens, and mocks innovations in education, democracy, as well as the newly wealthy and their addiction to luxury and conspicuous consumption. He also mocks what he considers the useless war with Sparta. Much of Restoration comedy mocks the corrupt and dissolute practices of the aristocracy. Often comedy serves to correct what the playwright perceives as vices by mocking them. Molière stated of his own work:
Whereas the duty of comedy is to correct men by amusing them, I felt that, being in that profession, I could do no better than to attack, by ludicrous portrayals, the vices of my age.