A SIM card typically has 8k to 256k of memory which stores MNC, ICCID,
IMSI, Authentication Key (Ki), Local Area Identity (LAI), and
Operator-Specific Emergency Number. The SIM also stores other
carrier-specific data such as the SMSC (Short Message Service Center)
number, Service Provider Name (SPN), Service Dialing Numbers (SDN),
Advice-Of-Charge parameters and Value Added Service (VAS)
applications.
Most SIM cards will orthogonally store a number of SMS messages and
phone book contacts. The contacts are stored in simple "name and
number" pairs: entries containing multiple phone numbers and
additional phone numbers will usually not be stored on the SIM card.
When a user tries to copy such entries to a SIM the handset's software
will break them up into multiple entries, discarding any information
that is not a phone number. The number of contacts and messages stored
depends on the SIM; early models would store as few as five messages
and 20 contacts while modern SIM cards can usually store over 250
contacts.
The SIM card has a special file where the SMS are stored, the file has
several "slots" in it, each slot holds a message. The number of slots
is finite, i.e. a SIM card can store 20 or 25 SMS (depending on the
capacity, newer cards have more slots). When all the slots are filled,
you have to delete an old SMS before you can save a new one.
[Paraphrased] Modern phones do not use this storage normally, but all SIM cards have this capability since it is part of the GSM standard.
SMS and Contact management are handled by applications on your device, in an Android this is typically your Dialer or Contacts application, and for your SMS messages this is handled by your Messaging application. This seems to be a thing of the past now though, as many apps do not include support for storing or retrieving user's SMS or contact information from the SIM card. SIM Manager is an example of one application that can help you manage the information on your SIM card.
Also note, your carrier may insert information such as a welcome message as an SMS message, or contacts such as their customer service, billing, or repair service numbers.
So the answer to your question is that both SMS and Contacts can be stored to the SIM card, but it's limitations likely mean the use of it for backup and transferring to another device in modern smartphones is extremely limited.