We can start with the popular definition: anything funny or amusing. That's not bad for casual conversation, but comedy is often used more precisely to designate a dramatic genre. It's commonly distinguished from tragedy and, especially in Shakespeare, from history as well.
Comedy tends to have a few features:
Since the term comedy is so broad, it's common to distinguish varieties of comedy. Greek comic drama, for instance, is usually divided into the Old Comedy of Aristophanes, with its emphasis on fantasy and political satire; and the New Comedy of Menander (and developed by the Roman comic dramatists Plautus and Terence), with its young lovers trying to get together in the face of obstacles. The New Comedy is probably the origin of the later comedy of manners, as seen in Shakespeare's plays and especially the comedies of the Restoration. There's also the comedy of humors, made famous by Ben Jonson in the Renaissance. "Humors" refers not to "sense of humor" (at least, not directly), but to the four fluids that in pre-modern medicine were assumed to determine character: blood, phlegm, choler, and black bile. When the humors were out of balance, some quality would predominate in the personality. Jonson and other authors of comedies of humors would depict eccentric characters marked by the dominance of one of these qualities.
It's not always easy to say what's in and what's out. Shakespeare's Henry IV plays are usually classed as histories they deal with kings 'n' stuff but the Falstaff scenes come straight out of comedy. Those who tend to think of satire as a genre may take care to keep it distinct from comedy, but a comedy may be satirical and a satire may be comic.
See also tragedy and satire.
Note: This guide is still in the early stages of development.
Three question marks mean I have to write more on the subject. Bear with me.