The events of the novel take place during an atomic war in the future, and the reason the boys end up on the island is because they are being evacuated from England to Australia for safety. Though they are just children, they too end up dividing into opposing camps and going to "war."
Golding himself was a member of England's Royal Navy during WWII and knew the kind of destruction the adult world could create. On his fictional island, he crafts a smaller stage for the same kind of ideological battle.
The ending of the novel is particularly ironic because the boys are found by a British naval officer who is disappointed by their savage and uncivilized behavior. As he looks at his "trim cruiser in the distance," the officer does not seem to make the connection that this small island world is merely mirroring the larger one.
There is a lot of social truth in the adult world, also. Every one of the characters represents some aspect of the adult world. I'm sure you can think of someone you know who acts like Ralph, Piggy, Jack, Simon, etc. Golding was able to take whole social circles and personify them in one character. For instance, Simon represents all of those people who are lost in thought of what's bigger, what's out there, what's possible. Piggy represents all of those people who have rational thoughts and answers to serious problems but aren't taken seriously for other reasons, and so on. The social aspect of this novel was a pretty serious undertaking, but Golding was able to effectively portray and adult society on this island.