Jailbreaking is legal in many countries, including the US, under certain conditions. However, it may void your device's warranty, and Apple discourages it.