Many critics believe author Shirley Jackson was greatly influenced by the events of World War II and the rise of Communism that followed shortly after. The rise of Nazi Germany is one example. The German mistreatment, deportation and murder of millions of their own people happened after the nation's citizens refused to take a stand against Hitler and his henchmen, thus resulting in the Holocaust. The rise of Communism and Marxism following the war is another example. The Communist paranoia in America resulted in the McCarthy hearings in which citizens turned on their friends and neighbors.
You should read the "themes" section at the link below. There you will find some theories that have been advanced as to the purpose of this short story.
Shirley Jackson published this story first in The New Yorker magazine. Both she and the magazine received a lot of hate mail about the allegedly cruel story and many people canceled their subscriptions. In reaction to this, Jackson herself explained that she was trying to show man's inhumanity to man in the story, to focus on the inherent cruelty within the human soul. She reports that even her parents didn't like the story and urged her to write something nice.
The story underlines the danger of rigid thinking, perhaps even prejudices, and doing something just because it has always been done in such a way, a sort of human lemming theme. Lemmings are rodents who people incorrectly believe commit mass suicide when they migrate. The idea is that lemmings follow each other to their deaths just because that is what they do. In this short story, a few people question the purpose of the lottery, and yet no one has the guts to stand up and say, "This is evil!" This theme can apply to many negative aspects of human society, don't you think?