Hello, you can directly factory reset your old Mac without an Apple ID password because Mac OS X 10.5.8 is really outdated and has nothing to do with Apple ID. For factory resetting, you should erase the startup disk and then reinstall macOS on your Mac.
Let me show you how to erase the startup disk on your device first:
1. Boot your Mac into macOS Recovery mode. You should shut down your Mac, reopen it and press down the Command + R keys simultaneously until you see an Apple logo.
2. When the macOS Utilities window appears, select Disk Utility and then choose your startup disk (usually Macintosh HD).
3. Click Erase button on the top menu bar, fulfill the disk name, and choose Mac OS Extended (Journaled) in Format.
4. Click Erase to wipe the startup disk for macOS reinstallation work. After the erasing work, quit the Disk Utility window.
After you have erased the startup disk, you can reinstall macOS now.
1. Click the Reinstall macOS option and click Continue.
2. Select a destination to install the new copy of macOS and select the startup disk you formatted earlier.
3. Click Continue to begin the reinstallation. You will see a window with a progress bar and time remaining for installing OS.
It will take some time, please don't let your computer go to sleep or shut down. After the macOS installation process is complete, your Mac will restart to a setup assistant, and you can complete the reinstallation by following the on-screen wizard.
For more information, please read: How to Completely Reset a MacBook Pro/Air to Factory Settings