Recently my first generation Intel iMac that I've had since 2006 has begun to lock up and restart on me. Before I run off and spend $1500-$2000 on a new iMac, is there any good way to diagnose the hardware? I would like to know exactly what is going wrong so I know I won't be wasting my money when there is an easier fix.
The first thing to do is open up Console in the Applications/Utilities folder and go through the logs to see if there's anything that happens before you lock up / restart.
There are a couple different diagnostic utilities to check for hardware problems you could try:
TechTool Deluxe is the utility that comes with Applecare.
Applejack is a utility you run after you reboot in single-user mode.
You could also hold down D while rebooting your computer. That will start the built-in hardware diagnostics. Since you have an older Mac, you'll have to do this with the Applications CD that came with the computer in the drive slot.
The problem is not necessarily hardware related, so hopefully you'll find something in the console that shows some software trouble whenever your Mac locks up.
However, given the symptoms you describe, it sounds like it might be a System Management Controller corruption (presuming it's an intel-based iMac). I would try to follow these instructions to reset it.
If you have the original DVD's that came with it, there should be two: one for the OS install and one for the Applications install (iLife, etc). You can boot to the applications DVD and run a hardware diagnostics check on your system. More info: http://support.apple.com/kb/ht1509