In the broadest sense, all literary works can be placed into one of two categories: comedy or tragedy. A comedy has a happy ending, meaning that the protagonist doesn't die or suffer a crushing blow from which he can't bounce back. In a tragedy, the protagonist does die (or suffer a horrible fate, as when Oedipus blinds himself and accepts exile).
The Divine Comedy is called a comedy because it has a happy ending. At the beginning of the poem, the thirty-five-year-old Dante is lost spiritually. Halfway through life, his faith is draining away, and he feels as if he is stumbling around in dark woods. Beatrice, the Virgin Mary, and St. Lucia are concerned for him. They arrange for him to tour hell, purgatory, and heaven with the hopes this knowledge will set back on the straight path of faith.
This is a long journey, and Dante has much to learn, but in the end, Dante's heart has been fully transformed. He is able to ascend to heaven and into the Empyrean, where he sees God. This fills him with an overflow of love and wisdom that saves him from eternal ruin. Thus, this is a comedy: it has the happiest of endings for the protagonist.
The lesson, too, is that Dante is an everyman (or woman) figure. Redemption is possible for all humans if they follow the Christian path of virtue, faith, love, and hope.