Light rattling is normal. Do not worry about this unless the phone is having some sort of performance problem. It's often one of the buttons, but it could also be a moving part of the camera and nothing to be concerned about. However, if the rattling is solid and it feels like there's a big rock moving around in there, it could be a loose battery or something and you will definitely start experiencing problems with the phone.
The rattling noise that when you tap lightly on the top of the iphone 5 is the vibrator unit, vibrator unit is actually a tiny motor attached to a piece of off-set metal, it makes your phone "shaky" when is activated, because it design to "shake", so when it is not "shaking", it is loose, that's why you will hear the rattling noise.
To confirm it, you will hear the same thing on the iphone4 (GSM) when tap on top adjacent to the camera. For iphone4s, you tap somewhere just below the micro-sim slot, you will hear that noise too. iphone4 has a typical "motor" looking vibrator, while iphone4s has a rounded, coin-battery looking vibrator.