Can you tell us more about the "P8": is this a Huawei P8, or a P8 Lite, or something else? Precise model number is safest. Knowing whether it was bought unlocked or sold through a service provider might also be important. (I'm not familiar with Huawei devices, but the exact model number is always a good idea and the other stuff is often relevant).
Rooting is not a generic process: although there are common general approaches (unlock bootloader, replace recovery module with a "custom" version, use the custom recovery to modify the ROM to give you root access) not all devices allow this and so the techniques and tools vary between devices. Software such as custom recovery modules must always be built specifically for the particular model. Some phones cannot be rooted.
When asking about legality it's always sensible to say which country you are in (e.g. in the UK it's illegal to modify a device's IMEI, in some other countries there may not be such laws). In general rooting is legal, and as long as you make sure you understand what you are doing before charging in it's also safe. But you should understand what it does, what it does not do, and what the side effects might be.
You say rooting "can remove all the software restrictions on an android device". That really depends on what software restrictions you were thinking of. All that rooting actually does is allow you to run user-installed apps with administrator privileges. That's it. So before doing it, ask what you want to do using this ability. (People often confuse things like the ability to replace the recovery or ROM with rooting, but that's actually a consequence of unlocking the bootloader).
Rooting has downsides: if you can run apps with admin privileges, any malware you unwittingly install can also use those privileges. This means that you have greater responsibility for your own security. This is also why sensitive apps such as banking and electronic payments will try to detect whether your phone is rooted and will not work if it is (because being rooted would make it easier for malware to obtain sensitive information from other apps). Some less important apps (some games and media apps) will also try to block rooted devices. Some rooting tools (e.g. Magisk) have tools to "hide" the rooted status. Whether the apps you care about can still work after rooting is something you should find out before proceeding. Modifying the ROM will probably prevent you installing future over the air updates, but that's probably not a problem with an older phone.
As you'll have gathered from this I have rooted phones in the past. But my current phone is not rooted, so I'm not wholly up-to-date in my knowledge, and I've never owned a Huawei (or any other device called P8) so can't offer very specific help with your device.