No one knows why Boo Radley left the gifts in the knothole for Jem and Scout, but perhaps Scout explained it best in Chapter 31. It was because Boo was "our neighbor."
Neighbors bring food with death and flowers with sickness and little things in between. Boo was our neighbor. He gave us two soap dolls, a broken watch and chain, a pair of good-luck pennies, and our lives. But neighbors give in return. We never put back into the tree what we took out of it: we had given him nothing, and it made me sad.
Scout's great wish finally comes true when she sees Boo for the first time. He had "sickly white hands that had never seen the sun... His face was as white as his hands... His cheeks were thin to hollowness... his grey eyes were so colorless I thought he was blind. His hair was dead and thin..." (Chapter 29)
Harper Lee never directly states Boo's reasoning for leaving the children gifts in the knothole of the tree, but one can infer that Boo was attempting to communicate with them as a way of developing a friendship. Initially, Jem is unsure of who is responsible for leaving the gifts but has a hunch that it's Boo. In Chapter 7, Scout describes Jem's reaction to almost telling her by mentioning,
"He had been on the verge of telling me something all evening; his face would brighten and he would lean towards me, then he would change his mind" (Lee 37).
As was mentioned in the previous post, Scout's encounter with Boo Radley at the end of the novel somewhat reveals Boo's intentions for leaving the gifts. Scout comments,
"Neighbors bring food with death and flowers with sickness and little things in between. Boo was our neighbor. He gave use two soap dolls, a broken watch and chain, a pair of good-luck pennies, and our lives" (Lee 171).
Lee suggests that Boo is simply being a good neighbor. Since he is so reclusive, the only way to show that he is a good neighbor is to give the children gifts in the knothole. As Scout stands on Boo's porch and views the neighborhood from his perspective, she says,
"Fall, and his children trotted to and fro around the corner, the day's woes and triumphs on their faces. They stopped at an oak tree, delighted, puzzled, apprehensive" (Lee 172).
Boo noticed that the children were delighted to find the gifts in the tree which suggests that he intended to give them gifts in order to see the expression of joy on their faces.