What exactly is a SIM card?
There is a small microcontroller inside. 

Most SIM cards these days can be programmed in Java and follow the JavaCard / GlobalPlatform standard. You won't get the keys to install your own applications though.