happened to me on my first iPhone 4 on at&t. apple or sprint will try to replace the sim card first, or the sim try. however I've never seen this fix the issue in person or if you search google and read tons of others with the same issue over the years. my guess is that the actual sim card reader is shoddy in the phone itself.
i would suggest starting by cleaning the sim card contacts first with a q-tip and some alcohol. if that doesn't work, try a new sim card from sprint. if that doesn't work (didn't for me), take it to apple, as you may need a replacement device.