Dying for the group: What motivates the ultimate sacrifice?

Whether idolised as heroes or demonised and labelled terrorists, throughout history people have been willing to die for their groups and the causes they believe in. But why?