iMessage has also been the main source of hacks for iPhones for years if not decades. Apple really struggle with securing iMessage.
It definitely does not need to run all the time, it could be woken up by incoming notification like all other apps (and I hope it is how it actually works).