Ensure that all of your device's information and settings are backed up on an external device, including your current ROM. The device should be fully charged and have USB debugging enabled. You may also need to install a rooting program on your computer, such as Android SDK.
Many phone manufacturers, such as HTC, Motorola and Sony, offer methods for unlocking the bootloader on their websites. If your device's manufacturer does not allow customization, an alternative route may be available via the XDA Developers forum.
There are many tools used to root an android phone, such as Towelroot and Kingo Android Root. To root your device with Towelroot, simply download and run the app. If your device is a Motorola or HTC, or has a kernal bill later than June 3, 2014, then Towelroot may not work. In this case, use Kingo Android Root.
Use the Root Checker app to ensure that your device has been rooted. Finally, download a root manager app, such as SuperSU, to keep your phone protected after the rooting.