John Proctor wasn't going to die at first; he confessed to witchcraft to save his life. He did so because he felt himself a weak and sinful man. In the end, John tears up his confession after they attempted to get him to post the confession on the church door where his sons would see it, and live their lives thinking that their father either was a witch, or that he gave a cowardly lie to save himself. He gives his life to protect what he believes in most: honesty and integrity, two things that he always had, but had previously shown in rather unconventional ways. Elizabeth summed it up at the end of Act 4: "He has his goodness now." John finally felt at peace with his past, like he had paid for his sins, and was walking to the gallows with a clean slate. His death was his final testament to living honestly, owning your sins and walking with your head high in the world.