This play takes up a specific idea at its core: those who are right do not always win. Innocence and integrity sometimes lose when pitted against fear, hate, and a lack of accountability. In order to fully express this theme, John Proctor has to die in the end.
Proctor's final recantation of his confession and his refusal to put his principles aside to save his life, we see the triumph of personal integrity in a world of moral uncertainty.
This triumph for Proctor is also the reason he goes to the gallows. He stands against the corruption and immorality of those in power.
Proctor will not be saved by innocence, his moral code, his honor or his intergrity. The town's collective fear leads to the condemnation and death of many innocent people. When the fraud of the accusations of witchcraft is recognized (by some), the collective fear does not turn into collective guilt.
...rather than take a stand against proceedings they suspect are unjust, the townspeople of Salem go along with the trials.
The judges are not accountable for their actions and neither are the girls who make many of the accusations.