iMac beachballing for no reason — I suspect it might be faulty hardware. What can I do to work around it?
I'm just going to echo Allan's comment: if DriveDx says your drive is "failing" then it needs to be replaced. The only workaround is to remove the drive and stop using it.

Disk health checks have a low sensitivity but high specificity. In other words, it might report that a failing drive still looks healthy, but it will never report a healthy drive as failing. If it reports failing, we must trust that result.

The reason that wiping the drive helps, at least for a little while, is that it does more work to avoid using the parts of the drive that are already known to be bad. But the drive is like a rotting fruit 
 -- even the good parts are going bad, so eating around the bad part doesn't help for long.