The most significant ways in which the setting affects the story is by contributing to the mood, and by increasing tension.
The setting which receives the greatest amount of detail is the swamp, and the old Indian fort found there, where Scratch resides. This detail, which is mostly concerned with communicating the dark, decaying, foreboding and haunted nature of the place, contributes to marking it as an evil place, one where we should expect a normal person to avoid. The fact that Tom seems perfectly alright with it tells us that he is either brave or foolish, although once we learn more about him it just seems that he's a bad person himself and we can comfortably judge his metaphorical book by its cover.
The swamp is also difficult to access, which has not only kept the treasure safely out of anyone's hands for many years, but it also makes it difficult for Tom to find Scratch when he wants to; this increases the tension by making it slightly unclear for us, and especially unclear for Tom, whether he will actually have a chance to go through with the bargain. This is intended, however, because Scratch means to build Tom's anticipation to the point that he's willing to agree to any terms.
There isn't much devoted to other settings in the story, other than the ending, where the approaching thunderstorm and the way Tom is "returned" to the swamp and the Indian fort, suggesting that the storm was a direct manifestation of the Devil's power.