There is a key value on the SIM. The same key value is also provisioned in your subscriber profile in your provider's main subscriber registry (aka an HLR - Home Location Register).
When you're connecting to a mobile network, the serving switch sends a request to your provider's HLR. The HLR sends a set of tokens and an "expected result" value to the serving switch. The serving switch then sends those tokens down to your mobile. Your mobile then sends those tokens to your SIM card and your SIM card sticks them into a function along with the key value and produces a result value. The result value is passed back to your phone and your phone passes it back to the serving switch. The serving switch then compares the result value from your phone with the "expected result" value from your provider's HLR and if they match up, you're good to go.
Only the SIM and the HLR know your individual key value. Your mobile and the serving network are never provided this value. That's why your phone can't simply replicate the function of your SIM, because it would need to know the key value.
I think the problem alot of people have is they think of the SIM as just a dumb piece of storage. It really is a separate little computer in it's own right that just so happens to live behind your phone battery.