Aristotle describes both types of theatre in his influential work Poetics.
According to Aristotle, the origin of comedy is in festivals and cheerful celebrations. However, the main requirement of a comedy is a happy ending. It usually describes the rise in fortune of a sympathetic character.
On the other hand, tragedy describes the downfall of a good person. This downfall is usually through an important error or misjudgement. The main character tends to go through a lot of suffering, and he causes a feeling of pity on the audience.