For Whom the Bell Tolls revolves around the idea of communion between human beings expressed in its epigraph. Connecting to others is the only way to overcome the emptiness and loneliness at the heart of each individual, especially in the hopelessness of war. It's their camaraderie which keeps many of the characters afloat. The most everyday activities and expressions of friendliness – being humorous, telling stories, touching, even swearing together – preserve some sense of normality, of humanity in the midst of "barbarism." The protagonist is transformed by the bonds he forms with the people around him over the course of only a few days.
It is seeing his sacrifice as something he does for his friends that gives Robert Jordan's death a purpose, and that serves as his ultimate consolation.