In its simplest form, iCloud is merely a special folder. It lives on the iOS device in /private/var/mobile/Library/Mobile Documents/. That folder hosts all application material that applications share to the cloud.
Applications have partial permission to read from and write to this folder. That permission is developer-specific. As with the password keychain, developers can share cloud data between applications.
For example, all apps developed by App Company X could share, view, and update the same document set. You cannot share data outside of your developer account. So my apps cannot see App Company X documents, and vice-versa.
The Mobile Documents folder is monitored by iOS. When files are modified, the device automatically uploads changes to the cloud. Those changes propagate out to all other devices registered to the same account. This is handled by a local OS service, and applications aren't directly involved.
Instead, applications subscribe to a variety of classes and notifications that allow them to know when changes occur. They can then resolve conflicts to bring local data into harmony with the iCloud versions.