I see that no one has responded to your post. If you can answer a few questions, it may help the community to better understand your issue:
1) What happens exactly when you attempt to login with your Apple ID on your iPhone?
2) Do you get a specific error message when you try to sign into iMessage with your Apple ID?
3) Have you tried restarting your iPhone to see if the issue persists?
4) Have you tested this using both Wi-Fi and cellular data to see if the issue persists?