Yes, Android Rooting is legal in most countries, as well as many smartphones legally allow to root devices such as OnePlus and Xiaomi. But on the downside, you will lose the warranty.