Firstly make sure you have fully backed up your phone including the SD card as unlocking will completely reset you phone & wipe the SD Card. remove SD Card if possible, if it's a built in SD Card connect phone to PC via USB & make a copy of it. I can't stress this enough unlocking bootloader & rooting will cause you to lose all the data on your phone & reset it back to Factory Condition.
Open this link (I can assure you it's 100% safe, it is one of HTC's own sites) :- Welcome to HTCdev
To the right of the M9 Image you will see 3 small boxes, click the 'UNLOCK BOOTLOADER', then click 'GET STARTED'
Now just follow the instructions.
Hope this helps you.