In addition to the above information I feel the need to break down "rooting".
As when people say "Root your device" they mean 1 or more things.
Root is the SuperUser (su) of the operating system.
Gaining root allows you to do many things, however further things of rooting...
Root (gaining the super user privileges)
Unlocking your boot-loader (to allow flashing custom recovery ROM which in-turn makes it easier to flash custom ROM's to your device).
S-OFF - S for Security (allows you to flash deeper hardware level firmware to your device.)
You can gain root (depending on your device) with the stock ROM.
You can unlock your bootloader without gaining root, just as you can flash a custom ROM which does not make you gain super user privileges (root)
You can gain S-OFF, and gain S-ON without rooting or unlocking the boot loader (depending on your device).
Some do all 3, Some do only 1 of the above, Some Unlock the boot-loader, to install a custom rom which has root, but don't S-OFF.
See further guides for more information on all of the above.