There are many things it could be and unfortunately, it's a process of elimination which starts with mechanical first. Then a careful examination of electrical connections and wires.
If nothing shows after this then next I would look to the PC. It's not uncommon for PSU in the PC to start to fail and drop out but for fractions of a second which wouldn't be noticed in normal use but for CNC machine and it's critical timings this is a lifetime and would cause this exact thing to happen.
Likewise if using a parallel port card then it could be that dropping out or being interrupted by other software like Virus checkers etc. But I would expect that to show up sooner and more often so I would tip it's a PSU type issue.

After this, we get into the weird and wonderful world of noise and interferences from outside factors like Next doors radio or the Mrs running hair dryer, tumble dryer, etc.
So check the earth to the machine frame, which really should have been done when checking out the wiring etc earlier.

If you go thru the process of elimination the fault should show it's self eventually. I'd tip PC if it's not a mechanical issue.