Take out the rear view mirror pulling it gently by the foot (not the mirror!). If your mirror is auto dimming or has a receiver for the remote control, you should be very gentle with it (as in pulling it out knowing that the wire to the mirror has a limited length).
The courtesy light can be removed with the rearview mirror in place, but I won't recommend that (the plastic cover of the courtesy unit sticks under the foot of the mirror).
After the rear view mirror is removed you can easily pry out the complete courtesy light unit and see what causes the rattling. It might be the steel bracket for the mirror (sometimes (one of) the 3 Phillips screws come loose).
The courtesy light unit with the switches is pretty tight and I don't think that the unit itself rattles...
good luck & greetingz,
with a minor 600+k