If the time and date on your iPhone are not properly set, this annoying message will appear. Go to Settings, and choose General. You will see Date & Time. Make sure to choose Set Automatically, because that way, everything will be set correctly, including the time zone.
If you are using your home Wi-Fi, maybe something is wrong with your network. Turn off your router, wait 15 seconds and turn it back on again. Connect to your network, and start iMessage again.
Click on Settings, go to Messages, click on Send & Receive, tap on your Apple ID, and then choose Sign Out. To sign in again, click on Use your Apple ID for iMessage. Enter your ID. Check if the iMessage is working now.
In Settings, turn the Airplane Mode on. Leave it that way for several seconds, and turn it on again.
Go to Settings, General, and choose Reset. Click on Reset Location & Privacy. Your passcode will be needed, and once you enter it, follow the given instructions.