An unlocked phone is exactly what it sounds like: a phone without restrictions. Most handsets, whether iPhone or Android, are often locked to a particular carrier (Verizon, AT&T, etc). These phones have software installed that prevents them from operating on a different carrier. Therefore, purchasing a locked phone from T-Mobile will only work with a T-Mobile SIM card.
The advantage of a locked phone is that a consumer can enter into a contract with a carrier to get a heavily subsidized phone. However, these plans are often lengthy and can be expensive over time. Therefore buying an unlocked device means using it with any mobile network. This can significantly reduce your monthly bill and affords more flexibility as you can switch carriers anytime.