I have a very old Mac OS X 10.4.11,
We do not know from "a very old Mac OS X 10.4.11," what exact iMac sub-model you have, but many were fitted with optical drives having a "fail-safe" device. If the drive fails, an internal block would deploy to prevent insertion of more disks. If you cannot insert a disk at all, the drive is dead and not recoverable. If it accepts a disk and then spits it out, it could be simply dirty.
Slot-load optical drives get filthy, especially if seldom used. Before giving up I would invest US$5-10 in a drive-cleaning disk and see if that wakes it up.
I have used a a cleaning disk to successfully resurrect seemingly dead slot-load drives in older Macs. In three of the cases an Apple tech had examined the computers and pronounced the drives dead and in need of replacement at a cost, at the time, of US$140.
Worth a try.