In Chapter 2, Miss Caroline notices that Walter Cunningham Jr. does not have a lunch. She offers him a quarter, but Walter declines her offer. Miss Caroline offers him the quarter again and tells Walter that he can pay her back tomorrow. Walter shakes his head "no," and one of Scout's classmates whispers to her, "Go on and tell her, Scout." (Lee 26) Scout mentions that all of her classmates were looking towards her and had assurance she would be able to explain Walter's situation. Scout says that she "graciously" rose on Walter's behalf. Scout attempts to explain that Walter is a "Cunningham," and there are certain traits that define his family. Walter refuses to accept Miss Caroline's quarter because his family is poor and he will not be able to pay her back. The Cunninghams never take anything that they cannot pay back. Scout comments, "You're shamin' him, Miss Caroline. Walter hasn't got a quarter at home to bring you, and you can't use any stovewood." (Lee 28)
Scout defends Walter because she understands that he is too embarrassed to tell Miss Caroline he cannot pay her back. Scout is familiar with his family and is by far the brightest student in her class, which explains why all her pupils looked towards her to defend Walter. Scout had previous run-ins with Miss Caroline earlier in the day, and her failure to convey the Cunninghams' way of life is her last straw. Miss Caroline picked up a ruler and gave Scout six "pats" across her palm as punishment for her behavior.
Scout explains Walter's situation to Miss Caroline because Miss Caroline is not from Maycomb and does not understand Walter's background.
Miss Caroline offers Walter a quarter to buy lunch for the day and tells him he can pay her back the next day. Unfortunately, she does not know Walter comes from a very poor family and that he will not have the money to pay her back the next day. He won't have the money ever.
This is a moment where Scout is trying to do the right thing and it doesn't turn out well for her. Miss Caroline does not understand that Scout is attempting to help, gets frustrated with her, and ends up slapping her hand with a ruler (a pretty common form of punishment in schools at that time).