Jailbreaking is generally legal in many regions for the purpose of installing software, but it voids your warranty with Apple.