My view is that requiring the user _not_ to unlock the phone is a perfectly reasonable element of the agreement between the user and the phone provider. It's all about what both sides are getting -- and it's certainly true that you are not getting an unrestricted device. But, I would dare say that everyone has a certain price at which they would find a restricted device to be worthwhile. So, the qualitative aspects of such a transaction are absolutely fine and it's perfectly reasonable for the law to uphold that.
Most of the time, contract law is sufficient to handle such agreements between service providers and their customers. Why should unlocking phones be given special treatment under the law? Early termination fees are very enforceable and generally seem to be sufficient to stop people from breaking their contracts.