The easiest way is to obtain the unlock code sequence from T-Mobile or visit a T-Mobile store and ask for it to be unlocked. There are also third-party services that offer telephone unlocking. Most other methods risk permanently damaging the phone.
First option is to call T-Mobile and ask for an unlock code for the phone, so that the unlock will be safe. If not, get a custom Bootloader, and boot from it to run a program to unlock it, downloaded from a unlocking website.
As far as I know, Motorola Razr GSM is unlocked by using code, which is the safest and simplest way. Unlocking with software is not safe. Codes will be generated from server based your phone IMEI number.