Rooting is legal, but it can void your device's warranty. You should check your device's warranty before rooting it.