If you've successfully logged in Apple ID by erasing all data but found that the iMessage and FaceTime on your device couldn't work, you may have to reactivate them first.
For iMessage: Try to take out your SIM card and resert it again. Then go to Settings, tap on Messages, add your Apple ID and password to activate your iMessage. This method can be used when your Apple ID works fine but the Sign in greyed out in activating your iMessage. After that, you can use your iMessage over Wi-Fi with the Apple ID.
For FaceTime: Directly open your FaceTime app, tap to enter your Apple ID and password if the option in the settings greys out too. After that, your FaceTime should be activated as well.