The theme of political legitimacy is dealt with through the initial conflict of Prospero's loss of his dukedom; through his treatment of the other people on the Island; through the tempest Prospero conjures; and through his eventual relinquishing of his magic "Art." A note is in order first to specify that Shakespeare would not have thought in terms of "political legitimacy" as this is a new linguistic construct defined by modern political organization.
In the first place, Prospero loses his Dukedom through the mechanizations and intrigues of his brother. He had entrusted Antonio, his brother to act as regent of his dukedom of Milan while Prospero pursued studies. Antonio tired of being regent and conspired to become the new Duke of Milan. Prospero and his three year old daughter were sent to sea in a boat designed to drown them or strand them helplessly without out food or shelter. Here we have the question of legitimacy, and it has two sides. Was Prospero's extended sabbatical from governing a legitimate exercise of power in a ruler. Antonio thought not. Is it legitimate for Antonio to have wrested power away from an absentee ruler to legitimize his regency rule?
In the second place, on the Island, Prospero has absolute rule over the other few inhabitants. He enslaves those whom he chooses; punishes those whom he chooses; educates and shows mercy to those whom he chooses. Is this the legitimate exercise of political legitimacy? Do the kindnesses he shows fit with or contradict the enslavement ans punishments he bestows? Thirdly, Prospero conjures up a storm with his magic that is designed to wreck Antonio onto the shores of Prospero's island after which Prospero will turn the tables of justice and reclaim his rightful place as Duke of Milan. Does he have the right to wreak revenge in this way or was his usurpation actually legitimate because of his absence? In other words, is it an exercise of political legitimacy to conjure (manipulate) a raging tempest in order to achieve restitution and justice for former injustice?
Finally, when fate and his magic have turned all things toward Prospero's desired ends, he gives up his magic. This could symbolize a final relinquishment of the obsession that kept him from exercising legitimate political power to start with, which is what set him up for being overtaken by his regent brother, Antonio. If this relinquishment is a reconciling act of repentance on the rightful Duke's part, is it sufficient to restore him to political legitimacy, especially after his manipulations of events and people through magic?