In Chicago, it's done to keep the alleys clean. There's a long history of people digging through dumpsters and making messes, providing homes and hospitality for rats. A previous mayor had a real phobia about rats, and made locking up dumpsters a pretty serious rule.
https://c2.staticflickr.com/6/5244/5362943269_f1d08c480c_b.j...