Definition: In literature, the word ‘setting’ is used to identify and establish the time, place and mood of the events of the story. It basically helps in establishing where and when and under what circumstances the story is taking place.
Example: In the first installment of the Harry Potter series, a large part of the book takes place at the protagonist, Harry’s, aunt’s and uncle’s place, living in the “muggle” (non-magical) world with the “muggle” folks, and Harry is unaware of his magical capabilities and blood. This setting establishes the background that Harry has a non-magical childhood with other “muggle” people and has no clue about his special powers or his parents and is raised much like, actually worse than, regular people, till his 11th birthday.