It depends on the type of iMac you have, you don't mention the type of processor. If it has a G3 (iMac looks like a tube TV), it cannot boot into 10.5, 10.4.11 is its max OS. If you have a G4 (iMac has a dome as its base) it can run IF the processor is at least 867 MHz and have at least 512 MB of RAM. If you have a G5 (iMac has everything on the monitor), the only restriction is RAM. You can do an upgrade install on the HDD from 10.4 to 10.5. This allows you to keep all of your applications and documents. Only downside is that 10.5 drops support for the Classic Environment, thus Classic Mac OS programs won't work.
If you want to boot into 10.5 from an external device/drive, there are a few things you have to do. The device HAS to be firewire based, USB support didn't exist yet. The G5 has a firewire 800 port and finding hard drives with that connector is still easy to find on the internet. In order to install a bootable copy of 10.5 on it, you need to connect it to your iMac and go to Disk Utility (Applications>Utilities), Erase, format it to Mac OS X Extended (Journaled) and give it a name, then click Erase. It should give you the name and format you selected, but you need to select the scheme. Select Apple Partition Map, this is used for PowerPC based computers. Finally, click Erase. Once it is ready, you can install 10.5 on your external drive by inserting the OS disc in your iMac, restart and hold the C key to boot up from the disc. Select your external drive during the installation process and let the computer do its thing. To switch between OSs, go to Startup Disk in the system preferences, select the system folder, and restart. Or you can hold the Option key while booting to select from the HDD and the external drive.
That was a lot of typing, hope it helps!