It's one of the seven deadly sins, and for a reason. Greed, especially in this story, makes people do not-so-smart things (like fall in a chocolate river or build a violent, faulty robot). You'll notice that almost every greedy person gets his comeuppance in this book. The world of Charlie and the Chocolate Factory is not one that tolerates selfishness. Despite the fact that it's an unfair world, where the selfless Buckets struggle to get by and the selfish Salts succeed, Dahl makes sure everything is right side up in the end (and in the chocolate factory), and rewards the Buckets with a well-deserved new life.
Everyone in this book is greedy, and Charlie and Willy Wonka are no exception.
Greed is good. When characters are greedy, it often pays off.