Why do Tom and Huck go to the graveyard?
The section of the book that you are talking about is a hilarious section. Huck and Tom sound like a couple of old men sitting on a porch having a ridiculously silly argument over nothing. The two boys are discussing the proper to way to get rid of warts. The two boys toss back and forth some ideas that they have heard and take turns shooting down the other boy's theory. The conversation finally turns toward the dead cat that they have sitting with them. Huck claims that a person can use a dead cat to cure warts. The trick is to take the dead cat to a graveyard, say a special incantation over the grave of a freshly dead evil man, and throw the cat after his spirit. Warts gone. Huck and Tom go to the graveyard to test the theory.
‘Why, you take your cat and go and get in the graveyard ‘long about midnight when somebody that was wicked has been buried; and when it’s midnight a devil will come, or maybe two or three, but you can’t see ‘em, you can only hear something like the wind, or maybe hear ‘em talk; and when they’re taking that feller away, you heave your cat after ‘em and say, ‘Devil follow corpse, cat follow devil, warts follow cat, I’m done with ye!’ That’ll fetch ANY wart.’
In The Adventures of Tom Sawyer, Huck Finn tells Tom the cure for curing warts and that is what takes them to the graveyard. Hucks states, ""Devil follow corpse, cat follow devil, warts follow cat, I'm done with ye!"(Twain).
The catch is that Tom and Huck have to swing a dead cat over a freshly buried dead man said to be evil and state the above encantation. So in the light of a full moon, Tom and Huck go to the graveyard and see Injun Joe murder Doc Robinson while graverobbing. Muff Potter, the town drunk is implicated, but fear and a secret oath keep the boys from revealing the truth.
I've included a link to the full text here.