In Android, all applications have User ID numbers. These ID numbers let the OS identify the apps and what privileges they have and to what they can access to.
There is a special user, whose ID number is 0. That is the root user and it has all privileges and can access everything.
When you root your device, you add a binary that lets other apps run with the privileges of the root user. The moderation of this binary is usually done with a GUI application like SuperSU.
Alternative methods of rooting have been invented after Android 6.0 implemented new bug fixes that prevented the traditional method from being used.
Also, with the introduction of SEAndroid, root user too now can be enforced to act in a way that it doesn't have limitless power anymore.