What event causes Charlie to eventually acquire the Chocolate Factory in the book Charlie and the Chocolate Factory?

Charlie acquires the Chocolate Factory after Willy Wonka decides to give it to him as a gift for being the most honest, kind, and humble child among all the other children who visited the factory during the tour.