Messages in phone are not lost when you change your SIM card but if messages are stored in SIM card, you can copy then to phone.
To copy SIM messages to phone do the following:
1. Open Messages
2. Press Menu and select settings.
3. Scroll down and select "Manage SIM messages"
4. Select Messages in SIM and copy or move to phone memory
Now when you change your SIM, these messages will remain in the phone
But, if you mean changing the phone, download a simple program called SMS backup & Restore.
It will backup your messages to memory card in a file. You can save the file on pc and restore your messages to other phone when you change your phone.
Here is Android Market Link to download SMS Back & Restore:
Reply in case of any problem.