iMessage inconsistently failing to work after Sim card swap
Have you tried resetting the network settings with iMessage turned off?

To reset your network settings, tap 


Settings > General
Then scroll down and tap Reset > Reset Network Settings


When the device restarts, turn on your iMessage again and let it activate.