The ruling came in stages, as with alcohol. The Quran first said that in wine and games of chance there is great sin and some benefit, but the sin is greater than the benefit. Later it said that strong drink and games of chance are an infamy of Satan's handiwork, that Satan wants to cast enmity and hatred among you by means of them and turn you away from the remembrance of Allah and prayer, and it asked, 'Will you then desist?' The Prophet ﷺ was so strict about this that he said whoever says to his friend, 'Come, let me gamble with you', should give charity, which scholars explain as an expiation even for the words.
The wisdom is easy to see. Money changes hands without work, a service or a fair exchange, and the loss often falls on those who can least afford it. Gambling is also addictive, ruins families, and trains the heart to depend on luck instead of effort and on Allah's provision. The rule covers casinos, poker, slot machines, sports and online betting, and lottery tickets, where you pay for a chance to win. Scholars apply the same logic to paid mystery boxes and games in which a purchase buys a random chance of a valuable prize, although this is a newer question and some scholars treat it differently.
A raffle or prize draw that costs nothing to enter is generally considered permissible, because nothing is staked. If gambling has become a habit, treat it as an addiction: tell someone you trust, use blocking tools, seek professional help, and repent. The door to repentance remains open.