As a (former) beverage manager in Las Vegas, I can tell you that several of you have pieces of it right.
1. The casinos pay per bag, negotiated rates, etc. No freebies. There's virtually no advertising available, so Coke or Pepsi wouldn't realize any return on their investment.
2. Free drinks are to get you drunk, so you lose control of your wallet.
3. They are also to keep you in your spot gambling. You and your machine or table game form an equation of profit per hour. If you and everyone else takes a 5-10 minute break each time you needed a drink, they lose thousands of hours a day in profit.
4. You get so many drinks out of a bag that each one is essentially free, anyway, but...
5. A comped drink is a tax deduction (and not at the cost of just the syrup, either), which helps to offset the ridiculous profits we make and have to pay taxes on.