Hmm, that is weird. I'm on my 5th iPhone since 2008, and still have all the old ones (app developer, so I used them all for testing). None have had issues, and I admittedly use them hard and sweat a lot when working or during sports -- I had both a 4S and 5 in my pockets while we were building our house and pier in 2012-2013 (tidal river, so mildly salty) and no issues despite being exposed to moisture, dirt, and sawdust. I have been surprised how tough the phones are and that they keep on ticking after I clean them up. I sometimes use a case, but most of the time do not. When biking, boating, or skiing, I put the phones in a ziplock bag and then in my pocket for extra insurance. Saved my iPhone 5 when out in my boat back in December and I mistakenly sat in a puddle on the seat.
I think that moisture sensor is the telltale -- is it possible the phone got wet without you knowing? Is it in a case that could have trapped moisture? Somehow it got wet.