In the USA in 2006 the DMCA created an exemption which Allow You to Unlock Cell Phone legally. Up to this point unlocking a mobile was considered an infringement of the carrier’s rights. Carriers often exploited this situation and forced users to pay enormous fees to unlock their device or be forced to discard their phone and buy a new one.
This situation differs throughout the world, which each country having its own legal frame work in place. The general rule appears to be that if you have paid for the phone, regardless of the fact that it may have been subsidises them you are entitles to do whatever you like with the phone.