He was the rightful Duke of Milan who (with his daughter, Miranda) was sent off on a boat to die by his usurping brother Antonio. Prospero and Miranda survived on the boat and found exile on a small island. He had learned sorcery and uses it while on the island to control the other characters. On the island, he became the master of Caliban and Ariel.
By chance, Antonio sails near this island and Prospero conjures the eponymous tempest which forces him (and others) ashore. Prospero regains his dukedom from Antonio through the events of the play.
However, at the end of the play, Prospero drowns his books and renounces magic. In the view of the audience, this may have been required to make the ending unambiguously happy, as magic smacked too much of diabolical works; he drowns his books for the same reason that Doctor Faust, in an earlier play, futilely promised to burn his books.
Now my charms are all o'erthrown,
And what strength I have's mine own,
Which is most faint: now, 'tis true,
I must be here confined by you,
Or sent to Naples. Let me not,
Since I have my dukedom got
And pardon'd the deceiver, dwell
In this bare island by your spell;
But release me from my bands
With the help of your good hands:
Gentle breath of yours my sails
Must fill, or else my project fails,
Which was to please. Now I want
Spirits to enforce, art to enchant,
And my ending is despair,
Unless I be relieved by prayer,
Which pierces so that it assaults
Mercy itself and frees all faults.
As you from crimes would pardon'd be,
Let your indulgence set me free.