Before Jailbreaking for the first time, Users wonder, Is Jailbreaking Illegal?. Short answer: Yes, it is Legal to Jailbreak. But I encourage you to read on.

In July of 2010 the United States Government ruled that Jailbreaking is legal and does not violate any copyright laws.
Source: escapistmagazine.com

However though, as stated in Apple's User Agreement, Jailbreaking an iDevice voids the warranty. So if you are taking your iPhone or any other iDevice in for maintenance and you have jailbroke it, It would be in your best interest to do a clean restore before the Apple people inspect it.