This started happening to me on my iPhone 5s today.
Only using the official wall charger and cable that came with the iPhone, i had it plugged directly into an outlet at a new office building. The 2nd outlet has a surge protector plugged in that has a Mac Pro, 30" Cinema, Lamp, and phone plugged in.
While attempting to write a text, random things were being accessed. Even the notifications screen swiped down while I was typing on the keyboard at the bottom of the screen. Once when I touched a letter it looked like the screen went through a dozen random things instantly.
So I shutdown the phone and powered it back on. It seemed to go away.
Later I was checking our company site through the phone. I found tapping links were not working. If I pinch zoomed and held, the webpage would erratically zoom in and out while my fingers were still.
My 2nd solution was to unplug the charge cable (at 92-94% charge)
Phone starts behaving normally without the charger. After plugging it back in, so far so good, except an initial stutter. Then again, it's also now 100% charged.
I thought maybe it's the stock iOS 7, since I haven't updated, but reports of this go back to the iPhone 4. Back then, it was often blamed on third-party chargers, which this isn't. So now I'm wondering, can it also be the outlet and not just the charger. Again, this is a new building, as we first moved in 2.5 years ago after completing.