How does iMessage work?
In a nutshell, iOS sets up a persistent connection to the Apple Push Notification (APN) servers if you elect to use iMessage, iCloud, Notifications or other push services. From there, the phone checks in with the servers anytime it has a network connection and listens for messages that the servers wish to push to your device. Furthermore, iOS then registers which applications on your phone should get specific messages. All the messages pass through the notification center system in case you have elected for them to be posted to specific places such as the lock screen, the notification tray or just passed off to the end application for each message as appropriate.
That's it.
- There's a server. (likely many behind a load balancer)
- There's a connection that your device opens to the server.
- Things can then arrive through the connection.
From a user perspective, this article should answer any questions you may have about iMessage:
http://www.macworld.com/article/162984/2011/10/ios_5_imessage.html
This is a more technical explanation of how Apple's Push Notification system works:
http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html