Atticus goes to the jail in hopes that his presence will stop people from dragging Tom Robinson out of the jail and killing him.
Earlier in the chapter, Jem and Scout overhear Heck Tate talking to Atticus about not wanting to keep Tom Robinson in the jail on Sunday night (the night before the trial starts). Tate is afraid that he won't be able to keep Robinson safe. At first, Atticus doesn't think that Tate's concerns are valid.
“They don’t usually drink on Sunday, they go to church most of the day…” Atticus said.
However, by the time that Sunday evening arrives, it's clear that Atticus is concerned about Robinson's safety. Atticus excuses himself from the house carrying a lamp and an extension cord and gets in his car. Jem and Scout both find this very odd, but they do go to bed as told. Of course Jem and Scout are way too curious about what their father is up to, so they sneak out of the house, get Dill, and begin searching the town for Atticus.
They find him sitting in front of the jail.
A long extension cord ran between the bars of a second-floor window and down the side of the building. In the light from its bare bulb, Atticus was sitting propped against the front door. He was sitting in one of his office chairs, and he was reading, oblivious of the nightbugs dancing over his head.
The three children then watch as four cars pull up, and a bunch of men step out of the cars. They approach Atticus and tell him to step aside. They have come to get Robinson. Atticus refuses to move and tells the men that they should go home. The situation is quite tense for a moment, and then Jem, Scout, and Dill run up to Atticus. It's at this moment that Atticus shows a bit of fear. He's now worried for the safety of his kids. The men threaten physical violence against Atticus and the kids; however, Scout is able to diffuse the situation by forcing Mr. Cunningham into a semi-conversation with her. Mr. Cunningham is unable to bring himself to continue with his original intentions, and he orders the rest of the men home.
I looked around and up at Mr. Cunningham, whose face was equally impassive. Then he did a peculiar thing. He squatted down and took me by both shoulders.
“I’ll tell him you said hey, little lady,” he said.
Then he straightened up and waved a big paw. “Let’s clear out,” he called. “Let’s get going, boys.”
Atticus definitely went to the jail in order to stop a lynching, but Scout was probably more successful than Atticus ever could have been.