The Adventures of Tom Sawyer takes place in the fictional village of St. Petersburg, Missouri in the mid-1800s. This is before the Civil War, so slavery is still legal, as evidenced by the presence of Jim, a young Black boy whom Aunt Polly enslaves. Tensions between white settlers and Native Americans were also high in this period. Missouri had only just been established as a state a few decades earlier, pushing Native people off of their homelands in the process.
The Village of St. Petersburg is based on Mark Twain’s hometown of Hannibal, Missouri, and the young characters like Tom and Huck are based on actual people with whom Twain grew up. Twain states this directly in his preface to the book: "Most of the adventures recorded in this book really occurred; one or two were experiences of my own, the rest those of boys who were schoolmates of mine." Twain sets this novel in small-town Missouri on purpose, seeking to satirize his experience of growing up in a hypocritical community where religious, seemingly moral adults say one thing and do another. (See, for example, the way that many members of the community try to pardon Injun Joe after he kills several people yet ignore and neglect Huck Finn, a child who has lost his mother and is abused by his alcoholic father.) Twain’s focus on the experiences of children in this setting allows him to illuminate the ways in which children are both freer than adults and more naïve.
As a realist novel, Tom Sawyer focuses on the lives of average, low-income people rather than wealthy, glamorous ones. Though there are certainly class differences between the characters (such as Huck and Tom), most characters in the novel are poor or lower-middle class.