The Bible: Jesus is the archetype of this character, though he's obviously not the first to have done so. Jesus had the advantage of knowing what was after death, and that he was going to sit at God's right hand... but he also knew he had to go through infinite pain. This is even more starkly illustrated by the fact that He said the line quoted below when discussing the subject, rather than something about the horrifying physical pain one would endure when dying of asphyxiation and blood loss during the crucifixion process, to the point where a word was made specifically to describe such pain: excruciating, or "out of the cross." In other words, the pain involved in his sacrifice was so much worse than torture that words could not describe it.
"Greater love has no one than this: to lay down one’s life for one’s friends."John 15:13
A divine being helping humanity through self-sacrifice has been an enduring theme in religion and mythology. See Prometheus, doomed to be chained for eternity with an eagle devouring his entrails as punishment for giving mortals the gift of fire. Although he was eventually freed by Hercules after a few thousand years. Legends say that even then, his punishment meant Prometheus had to wear a wreath and a ring of his chains for all eternity- and in respect, humans began wearing wreaths and rings as well.
The Book of Mormon, one of the four parts to LDS ("Mormons") scripture, tells the story of a prophet named Abinadi. King Noah was wicked: he and his priests committed murder and whoredoms and reveled in his riches, among other things, so Abinadi went to King Noah and told him that what he was doing is wrong, and that he needed to set things straight and repent. King Noah and his priests didn't listen and had Abinadi thrown out after warning him not to return. Rather than giving up and leaving, Abinadi returns in disguise and tells him his message again. The wicked priests try to kill him, but find that they cannot, and Abinadi says that they cannot harm him until he has finished saying what he came to say. After he finished, they burnt him to death, and while he is burnt to death, he prophecies that King Noah will also be burnt, which comes true. His death wasn't for naught, however, because one of the king's priests, Alma, listened to what Abinadi had to say, and then ran away from King Noah and repented. He alone helped thousands of people to find God, and many of the people who were righteous because of him converted thousands more.