SIM locks are implemented by manufacturers upon mobile network operator's requests. SIM prevents mobile handsets usually subsided by an operator to be used on other networks. SIM lock can be applied to any mobile equipment that operates with a SIM card. These devices include mobile phones, wireless terminals such us USB modems, wifi-routers, wireless gateways and wireless tablets.
As suggested by it's name, a SIM card (Subscriber Identity Module) is a module of identifying the identity of the subscriber. Every SIM card is associated to a 15 digit number known as the IMSI (International Mobile Subscriber Identity). The first 3 digits of this string of number is the MCC (Mobile Country Code) and the next 2 digits that follows is the MNC (Mobile Network Code).
In other words, network operator issues SIM cards and associate an unique 15 digit number to each card. Every SIM card that is issued in that particular country always starts with the same 3 digits. The next 2 digits are used to distinguish the various operators within that country. The remaining 10 digits can be further categorized to prepay and postpaid customers etc.
There are various types of SIM lock. The most common type is to lock to first 5 digits as mentioned above. For example, the SIM locked mobile handset sold in country 128 and operator 28 will only work with SIM cards that begins with 12828. Any IMSI numbers within the 128280000000001 to 128289999999999 range are accepted by the mobile device. If a SIM with IMSI that has any number other than these numbers, the device would display a message such as SIM lock or No signal. User will not be able to use that device until it is unlocked.
The types of locks can vary (eg. the number of digits to lock, to accept or reject a range, lock to multiple ranges), the alert message can be customized and unlock mechanism varies. For some device, users can enter a 6 digit unlock code at the prompt. Some requires a PC software program to unlock. Although there might be computer programs that can attempt unlocking by trying all possible combination (maximum 1 million combination), manufactures can set time-out period after 5 or 10 incorrect attempts. The SIM lock of most devices are activated at the factory level. (ie. at the production line) It would usually require an insider within the manufacturer to provide the 6 digits pseudo random unlock code.
There are countries that do no allow SIM lock for fair trading and fair competition reasons. There are also countries that allows SIM lock but consumers have the right to request for an unlock. Some countries "encourage" opeartors not to conduct anti-competition actions. While the SIM lock option is available, it is much easier for the manufacturers and consumers if the operators do no request SIM locks.