Since performing a jailbreak we do not violate the laws of our country (for example, in the United States jailbreaking is allowed), we have all the rights to it. Performing a jailbreak, the iPhone does not lose the warranty and is the same device as without a jailbreak.
Is Jailbreaking illegal? - No. Jailbreak is legal. If, after performing a jailbreak, you decide to turn in an iPhone for repair, Apple may not accept your iPhone. In this case, you have 2 ways - to demand to take an iPhone for warranty repair, since Apple has to fulfill it. The second way - before going to Apple, we recommend to remove the jailbreak from your iPhone and you will not be asked extra questions when taking it for repair.