A few days ago, near my office, there was a promotional event for some random brand of cookies. You could get a box for free, but only if you picked a winning ball in the mouth of a dragon statue.
I lost, but a friend shared its cookies. While crunching them, I wondered about all this staging. Why organizing a game of luck? Why designing a dragon statue?
It seems it's all about reinforcement, a concept in behavioral psychology. All of this is optimized so that I remember having received - or not - a box of cookies that day.
From Wikipedia: B.F. Skinner was a well-known and influential researcher who articulated many of the theoretical constructs of reinforcement and behaviorism. It used so-called Skinner boxes to study and change the behavior of animals.
Among many ways to perform behavioral reinforcement, one of the most effective is the "Variable ratio schedule" one. It means having a reward every N events on average, i.e. not always at exactly N retries.
That kind of reinforcement is "rapid, steady rate of responding; most resistant to extinction". No wonder if casinos still exist!
Such addictive schemes are used in game design. Candy Crush is a notable example of addictive gaming, read for example https://www.theguardian.com/science/blog/2014/apr/01/candy-crush-saga-app-brain