There are a few hints dropped in earlier chapters of Harper Lee's novel To Kill a Mockingbird that do prepare the reader for the surprise of what Boo Radley is really like.
1. He leaves small gifts for the children (e.g. the figures of the girl and boy in Chapter 7).
2. He mends Jem's pants (Chapter 7).
3. He puts a blanket around Scout (Chapter 8).
Boo hasn't been seen up to the end of the novel, of course, so his appearance is a complete surprise. That he's not a bloody-fanged raw-squirrel-and-cat-eater... well, that's pretty clear from much earlier in the novel.
Harper Lee does an excellent job of foreshadowing in To Kill a Mockinbird, and one of the key characters whose ultimate character is revealed to be far different from what society (as represented by Scout, Jem and Dill) expects is Boo. The gifts that he leaves for the children are only one example. From the start, he is painted as a strange (therefore evil) man; however, what is being represented in this portrayal is a major theme of the novel - society's mistrust of and animosity toward the "other" defined as anyone who exists outside of the 'norms' that govern the society in question.
In this case, two major "others" are examined: Boo (mentally handicapped) and Tom Robinson (African American). In both instances, society as a whole has outcast these individuals, but in different ways. Tom is an outcast because of his race. The results of the trial should come as no surprise to anyone who has any familiarity with the time period. Boo is an outcast because of his disability. At this point in time (and to be honest this has not changed all that much today) mentally handicapped people were institutionalized or "hidden" as it were from society. As a result, the general public did not understand mental illness and viewed it as a flaw that was then connected to evil.
To fully understand this, look at all of American history - from the Native Americans (dubbed savages) to the Salem Witch Trials (some of those accused were afflicted with mental illnesses) to the modern day tendency to alienate and label people who suffer from mental illnesses or mental retardation, the other has always produced a sense of fear. What Lee is getting at is the fact that the other may not be all that "different" and that different does not always have to be a negative thing. By carefully following her themes, the ending should come to no surprise to the reader.
In the book To Kill a Mockingbird it is not really a surprise that Boo Radley protected the children. The reader becomes acquainted with Boo as the story of his family is told by Scout. Boo has a history of having taken scissors and put them into his father’s leg. He was kept secluded from the world. The townspeople not knowing the truth could only develop their suspicions.
There is a lot of foreshadowing that gives the reader clues to the real Boo. When the children begin to find small treats and trinkets in the tree, Boo is demonstrating acts of kindness, and his effort to reach out. Jem left his shirt behind after a dare at the Radley yard. It was torn and Boo had tried to sew it up. The book does not tell us directly that Boo was the one who had sewed it, but there are subtle hints.
One of Atticus and the children's friend explained to the children that Boo had been a nice quiet child when he was young, a pleasant child. By putting the clues together the reader is able to preview the likelihood of Boo being a good person.