A pin is used to protect the SIM from unauthorized use. It is asked when the device is turned on. Note a SIM does not protect when the device is on. The device display lock does that. Without the PIN someone could put the SIM in another device and use it. If you enter the SIM incorrectly three times, it locks up. To open it, you must enter a PUK code. It is a much longer code that you get from the carrier or which was provided when bought the SIM. If you enter that ten times wrong the SIM is permanently disabled. The setting to change the SIM pin is in the security setting of the phone.