This sounds like an episode of Amazing Stories called Life on Death Row
Convicted murderer Eric Peterson, Patrick Swayze,is about to face his maker after holding off his execution with legal maneuvers for some four years.
Recovering from his injury at the prison hospital ward Peterson and the sergeant of the prison guard Meadows, Hector Elizondo, soon realize that he somehow obtain the power to heal.
With the governor not commuting or even granting a stay of execution for Peterson Warden Erhardt, almost in tears, has no choice but to have him juiced with a 2,000 bolt charge of electricity in the prison's execution chamber.
And from this description, we have the ending you described
In Amazing Stories, the inmate is brought back to life thanks to all the people he helped
Interestingly, that last article notes that this episode was from 1986, and King's novel, The Green Mile, was published in 1996. The similarities are certainly striking...