Since the poem is such a multi-faceted work, there are several answers to this question. First, as a great artist, Dante reflects the ideas, concerns, and attitudes of his time; The Divine Comedy is no less than a summation of the medieval European mind.
In a letter he wrote to his patron, Dante states that his goal was to lead his readers from the state of misery to the state of happiness. In other words, the poem is supposed to teach the reader.
Finally, Beatrice is a major figure in the poem. At the end of his poetic autobiography called La Vita Nuova, Dante says that he intends to write of Beatrice "that which has not ever been said of another." So, in addition to being a religious, philosophical, and political poem, The Divine Comedy is an astonishing love poem.
As the opening line of the poem indicates, the poet is "midway in the journey of his life" at age 35 and has lost his sense of direction. He doesn't know who he is anymore and is looking for divine guidance. He feels as if he is in a dark woods and can't find the route back to salvation. The poem emerges from the question "who am I?" which is answered as, with Virgil and Beatrice as guides, the narrator tours hell, purgatory and heaven. At the end, he shares his wisdom with the world: his soul has becomed aligned with God's love, as should all our souls.
Another, more pragmatic motivation, aside from dealing with questions of identity and salvation, was exile: Dante opposed a group in Florence called the Black Guelphs, and ended up banished, which is sometimes how great books get written. Because he could not participate in politics, he had time to devote to this magnus opus.