The casinos can indeed lose money. Consider if the actual result is patriots by 20. The bettors who gave 17 would win and the bettors who took 23 will also win.
Most casinos lay off the imbalance on their books, but that costs. And what if no one wants to bet on Philly unless you move the line to 28? The line can be at 28, but there would likely be much less action, and therefore much less profit for the casinos. Some casinos would rather have a bit of imbalance, which they can lay off; rather than having almost no profit and a "perfect" line.