Wonka creates a massive demand for his bars by hiding 5 golden tickets in bars around the world. The promise is an experience and prize beyond their wildest dreams if they are the lucky winner. Winning would mean fame and a rise in status. The first 4 winners do so from the efforts of their parents who want them to win. They are upper-middle and upper-class families who have the income to support the purchase of a massive amount of candy. Their children are coddled, spoiled, gluttonous, and disrespectful...and yet they still go to great lengths to make them happy under the premise of wanting them to have a better life than they did.
Once at the factory, Mr. Wonka sets out to find the person he deems worthy to win his ultimate prize. The kids are eliminated one by one due to their greed. Though Charlie and Grandpa Joe breaks the rules, they can find a solution and help themselves. (Ingenuity leads to success). Mr. Wonka starts to throw them out even though Charlie is the last child left. After an argument, Charlie makes the decision to be honest and return the "everlasting gobstopper" instead of giving it to the competition. This honesty changes Mr. Wonka's heart and he gives Charlie the factory (Honesty and being a good person leads to success.)
Beyond being a rag to riches story, this film highlights morality. In the time of sex. drugs, and rock&roll this movie shows the dangers of "sin". Clearly depicted in the winning children are sloth, greed, gluttony, and pride. Though it is portrayed comedically, the "how to be a better person" lesson is there. The Oompa Loompa songs articulate the lessons.