I always though Jail-braking or unlocking your phone (or any other device) was not legal, but I was wrong.
Times reports that The Library of Congress' Copyright Office has officially deemed jailbreaking exempt "from a 1998 federal law that prohibits people from bypassing technical measures that companies put on their products to prevent unauthorized uses."
Apple can still say jailbreaking voids your warranty, but you're not doing anything illegal by jailbreaking your phone and installing apps not approved by Apple. Other good news: Unlocking cellphones (to use your phone with another carrier) was deemed legal in this ruling, as was circumventing DVD DRM to use the video for educational purposes, documentary film-making, and non-commercial videos. Check out a more in-depth analysis of the ruling over at Ars Technica.
Source: Electronic Frontier Foundation