Solution is in the last paragraph, cool showing off of my knowledge below!
The iPhone has a small arm underneath the sim card tray which tells the iPhone if it has a SIM card inserted or not, when a SIM card is present, it separates the two metal contacts and so, because there isn't a current flowing the iPhone knows that there is one, and to start powering up and reading the SIM card.
There might, by the sounds of it, be a loose part which is short-circuiting the iPhone, usually from the high voltage line to naught voltage line, that would mean your short-circuiting your house! If you live in Britian you will (by law) have a GFCI (Ground-Fault Circuit Interrupter) If voltage is coming from the live to ground (or zero) then it shuts off the power supply, to stop you from getting electrocuted! In the UK they are annoyingly very sensitive.
As your iPhone is still getting charged a little that means it is passively charging the Lithium battery, which isn't good for the battery life! The iPhone has a miniaturised and adapted GFCI inside of it which will be limiting the amount of voltage the iPhone takes in. In other products it usually warns you and tells you, the iPhone doesn't. Apparently it would confuse people to say 'YOU MAY GET ELECTROCUTED or YOUR iPHONE WILL SOON EXPLODE!'
Don't worry it's not as serious as that, but, as you may have already guessed, you'll need to replace the module were the sim card tray goes. That would be your best bet.
Hope this helps!