It doesn't really have anything to do with replacing your phone because it's broken. It has to do with using a T-Mobile phone on the AT&T network, for example. Some phones are network/carrier specific and unlocking them allows you to put them on other networks/carriers.I need to knock on wood after typing this, but I've been really good about not breaking phones, so I've never needed a phone unlocked. I always figured you'd need an unlocked phone if you had a new iPhone (for example), broke early in your contract extension and needed a new phone.
I thought that's why they are so damn expensive on ebay.