Unlocking your phone for international travel is illegal if you live in U.S.
United States’ Digital Millennium Copyright Act (DMCA) Section 1201 [PDF] expired on January 26th 2013, which simply means that if you bought a phone in US under contract with one of the carriers then you cannot unlock your phone, unless your contract expires, or if you have paid off your contract.
What would unlocking do for me?
If you are traveling out of your country and want to use your cell phone with a local SIM card, you will need an unlocked phone. Cellphone carriers in US locks their phone when purchasing a new one under a one or two year contract. This prevents you from using them on other carriers. Since these locks are software-based, there are a lot of hacks out there to unlock your phone so you can use them on any mobile service provider; simply by switching out SIM cards.
The DMCA law applies to residents of US, so if you’re living outside of US then this doesn’t apply to you. Israel and Singapore are two other countries having legal restrictions against unlocking.
An unlocked phone allows you switch SIM cards while traveling (make sure to look for micro-SIM or nano-SIM in iPhone 4 and 5, respectively) and avoid expensive international calling and messaging fees that your provider may be imposing on you.
For all you travelers out there whom DMCA applies, unlocking your phone or having an unlocked phone (while under contract) is illegal and carries penalties up to $2,500 in a civil suit of $500,000 or 5 years in prison for criminal cases.
Unlocking versus jailbreaking
You may have heard of people ‘jailbreaking’ their phones, and this does not mean unlocking. Jailbreaking (in case of iPhones) and rooting (in case of Android) your phone opens it up to third party apps. There are softwares that allow you to just jailbreak your phone, which is perfectly legal (not for tablets though) until 2015. But most of them also unlocks your phone.