Twain uses his talents at description and, more so, his development of Tom and Huck's "world" in order to make the small southern town a character in its own right. While Twain could have just focused on Tom and his immediate acquaitances, he instead spends time "building" the people of the town and the beliefs that make up the town. He describes people like the judge and the widow, and gives the boys' time to flush out their characters in their conversations. Doing this makes the town "real", gives it "life", and therefore makes it a character.
The character is old, and traditional. The name of St. Petersburg helps to give it this feeling. It is an opinionated and, often, backwards and unfair character. It is prone to superstition and to gossip. However, it is a family character, strong in its belief to help others.
The link below will describe the town in detail, which should further help you in explaining its importance.