Lord of the Flies by William Golding was written in the context of World War II, which made an indelible impression on William Golding. Golding was an officer in the British army and participated in many important battles in the war. For him, as for many people in his period, one major moral issue was a question of how civilized western Europeans could commit atrocities like the Holocaust. A question this prompted him to ask was whether the British, as some of his compatriots assumed, were by nature morally superior, or whether their position was merely a result of their institutions and traditions. As the naval officer says when the boys are discovered:
"I should have thought that a pack of British boys... would have been able to put up a better show than that."
Thus the novel is a sort of thought experiment that asks what would happen if British schoolboys were removed from positive influences of law and tradition so that their untrammeled inner natures would emerge.
I believe World War 2 was going on at that time.