Panther will give you the best mix of software compatibility and still running reasonably fast. Tiger will run at a push and is compatible with pretty much all software for OS X at the moment. However, on 128MB RAM it'll be slow... even for Panther, more RAM wouldn't hurt. You should be able to pick up a couple of 512MB modules pretty cheap since the iMac takes standard PC100 DIMMs which were common as muck a few years ago. Maxing it out to 1GB of RAM will really speed up performance no matter what version of OS X you run... basically for OS X, the more RAM the better!
As for getting a copy of the OS, eBay is probably your best bet. Apple doesn't bother with CD keys or activation like MS does with Windows, so just having the physical disks is all you need to run it and getting a copy second hand isn't a problem. If you decide to go the Tiger route, you may still be able to find some copies new... but again, you'll likely find a better deal on eBay.
Oh and one word of warning... make sure you buy the generic OS X retail disks rather than the versions that ship with new Macs. Those ones only work on the specific machine they shipped with. You can easily tell those disks since they're a grey colour with white writing and don't have the OS X logo on them. Basically this is the sort of thing you're looking for:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=250195699472
...and not this:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=330195719476
Hope that helps [
] ]'>
Edit: One more thing... if you happen to have one of the 400MHz iMacs that has a CD-ROM drive rather than a DVD-ROM then make sure you get a copy of OS X on CD rather than DVD... obviously! Panther should be fairly easy to find on CD. Tiger is a little more rare since it only shipped on DVD, but Apple operated a DVD-CD exchange program, so it should be possible to find a set if you scour.
As for getting a copy of the OS, eBay is probably your best bet. Apple doesn't bother with CD keys or activation like MS does with Windows, so just having the physical disks is all you need to run it and getting a copy second hand isn't a problem. If you decide to go the Tiger route, you may still be able to find some copies new... but again, you'll likely find a better deal on eBay.
Oh and one word of warning... make sure you buy the generic OS X retail disks rather than the versions that ship with new Macs. Those ones only work on the specific machine they shipped with. You can easily tell those disks since they're a grey colour with white writing and don't have the OS X logo on them. Basically this is the sort of thing you're looking for:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=250195699472
...and not this:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=330195719476
Hope that helps [
] ]'>Edit: One more thing... if you happen to have one of the 400MHz iMacs that has a CD-ROM drive rather than a DVD-ROM then make sure you get a copy of OS X on CD rather than DVD... obviously! Panther should be fairly easy to find on CD. Tiger is a little more rare since it only shipped on DVD, but Apple operated a DVD-CD exchange program, so it should be possible to find a set if you scour.