You have to follow this path Settings -> iTunes Store and App Store -> Apple ID -> Logout
Turn off the iPhone
I turn it on again and re-enter the Apple ID. (If you test and continues giving error, pass the method 2).
Of the problem not been solved, it is best to restore the phone. To do it:
We connect the iPhone via the USB cable to the PC or Mac.
We do a backup.
Restore the iPhone to factory settings.
Restore from the backup.
Many users say that the first method works for them. Those who do not, the system restore the error message disappears. I hope you have been helpful.