I'm sure you will remember that one of Amir's betrayals involved the planting of money under Hassan's mattress in an earlier chapter of The Kite Runner. Amir celebrated his birthday by contriving to blame Hassan of the supposed theft of this money. The shame it brought Hassan and Ali when the money was found prompted Ali to pack up and move away from Baba's house. Placing the money under Farid's mattress was a symbolic way of cleansing Amir's sins from the previous episode, and he knew the money would help Farid's war-torn and poverty stricken family. Doing so anonymously and knowing it would be found after he left was also a way of forcing the family to keep the money without feeling obliged to Amir or sacrificing any sense of pride in accepting charity from their guest.