If your is a PPC iMac, like a G5, Leopard 10.5.8 is as far as you can go. Available (at a price) from Amazon or eBay.
If it is an Intel iMac you should be able to use Snow Leopard 10.6, but unlikely to be able to go higher. If you can run Snow Leopard, forget Leopard, SL is much cheaper!
Start by checking if you can run Snow Leopard:
Requirements for OS X 10.6 'Snow Leopard'
OS 10.6 Snow Leopard is once again available from the Apple Store:
and in the UK:
but nobody knows for how long it will be available.
To use iCloud you have to upgrade at least to Lion, but some functions are only available in Mountain Lion:
You can also purchase the code to use to download Lion (Lion requires an Intel-based Mac with a Core 2 Duo, i3, i5, i7 or Xeon processor and 2GB of RAM, running the latest version of Snow Leopard), or you can purchase Mountain Lion from the App Store - if you can run that:
When you have installed it, run Software Update to download and install the latest updates for Snow Leopard.