Yes, it is legal to unlock phones. More importantly, the FCC has mandated that all carriers should unlock phones for their consumers for free if a consumer so desires.