William Golding wrote Lord of the Flies as "an attempt to trace the defects of society back to the defects of human nature." Each of the four main characters plays a role in that theme as they spend time on this untamed island that eventually devolves into savagery. Piggy is the wisdom and knowledge none of the boys really want to listen to; Simon is the sensitive spirit of man who is quickly stifled as savagery reigns.
Ralph is the only one left, and he has to fight the battle against Jack's unfettered savagery on his own. In truth, Ralph is running for his life at the end of the story, and if the naval officer had not arrived, Ralph would not have survived. He has run as far as he can, out of the foliage which provided him some cover and onto the beach. Ralph begins to despair, knowing he is about to become the next sacrifice to the savagery of the island. Then he sees the unexpected naval commander and slowly realizes that his life will be spared.
Once he is able to comprehend that, Ralph begins to think about bigger things, such as what the events that transpired on this island say about the condition of human nature when it has no restraints.
Ralph looked at [the naval officer] dumbly. For a moment he had a ﬂeeting picture of the strange glamour that had once invested the beaches. But the island was scorched up like dead wood—Simon was dead—and Jack had. . . . The tears began to ﬂow and sobs shook him. He gave himself up to them now for the ﬁrst time on the island; great, shuddering spasms of grief that seemed to wrench his whole body. His voice rose under the black smoke before the burning wreckage of the island; and infected by that emotion, the other little boys began to shake and sob too. And in the middle of them, with ﬁlthy body, matted hair, and unwiped nose, Ralph wept for the end of innocence, the darkness of man’s heart, and the fall through the air of the true, wise friend called Piggy.
Ralph weeps for the way the boys have ruined this beautiful island, for the loss of Simon, "for the darkness of man's heart," and for the loss of a true friend whom Ralph did not fully appreciate when Piggy was alive. Ralph grieves for the end of his own innocence, for now he understands the capacity of man to do evil when there is nothing to restrain him. It is a weighty reality for a young boy to bear.