It is probably the sim eject button. there is a little pin in the hole that moves around. To test put the sim eject tool in the hole and shake the phone you should not hear it any more
Thank you everyone for your replies. I have done some additional research on the topic and apparently some types of vibration motors can also cause this rattling sound.
I just wanted to make sure I wasn't the only one having this noise.