Towards the end of the play, Prospero forgives his brother, Antonio, who "entertain'd ambition" and who is—as Prospero says—"Unnatural." Prospero also forgives Sebastian ("whom to call brother / Would even infect (his) mouth") and Alonso, who asks Prospero to "pardon" him.
Arguably, Prospero decides to forgive everyone because he pities them. He has enacted his revenge, and as Ariel says (in act five, scene one), his "charm so strongly works" his prisoners that to see them would make his "affections . . . become tender." Prospero's decision to forgive those who have wronged him is perhaps simply a result of his conscience and his pity being pricked by this utterance from Ariel.
In the play's epilogue, we might find an alternative, more complex reason for Prospero's forgiveness. In the epilogue, Prospero asks the audience to "release me from your hands" and "set me free." Many critics think that Prospero here could be speaking on behalf of Shakespeare. From this perspective, Shakespeare is asking the audience to let him now be free from the obligation of entertaining them with his plays; he wants to put down his pen, as Prospero wants to put down his wand.
This then, in a sense, is Shakespeare's retirement speech. Indeed, The Tempest was one of the last plays that Shakespeare would ever write by himself. If we consider that Prospero may be speaking this epilogue on behalf of Shakespeare, who is longing for freedom in retirement, this can perhaps help us make sense of why Prospero forgives everyone by the end of the play. By forgiving them, he is releasing them from their guilt and from their sin. He is giving them freedom because he, who is about to ask the audience for his, knows how precious freedom is.
He also grants them freedom in the final act of the play so that his request for freedom in the epilogue will seem more deserved and more sincere. Indeed, he says to the audience in the epilogue, "Since I have . . . pardon'd the deceiver . . . release me from your hands." In other words, Prospero is saying (on behalf of Shakespeare) that he has done his part and what is right, and now it is the audience's turn to do their part and what is right: it is now the audience's turn to set him free.