If you want to root your phone you'll need to unlock the bootloader (if not already done) and this will wipe your phone, there is no way around this (unless it's S-OFF)
www.htcdev.com/bootloader
Second step is to flash a custom recovery, TWRP is the preferred one
https://dl.twrp.me/m7/
Last...