First of all, is jailbreaking legal?

If it is, how do I do it on the latest iOS version?