Unplugging the speed sensor is a way to induce a problem, not solve it (its not a permanent problem just an error code, that on some displays you can shut off via the settings). So after you are done with checking that bit, plug that sucker back in again.
I'll echo the advice from
@BiggKidd . Usually when doing diagnosis on one of these mystery problems, after you have figured out that there is no visually obvious flaw in the wiring, you start replacing stuff. Cheapest stuff first and hope at some point the problem goes away. I would start with the wiring harness. Even though it may look like its fine, a wire could be compromised within otherwise intact-looking insulation. The wiring harness controls several different things so its a good thing to start with. The last item on the list would be the motor controller which is the opposite of cheap and easy to swap out.
If your motor is cutting out but the display is uninterrupted, then that should count out the battery as the problem, but I would still check the wiring from motor to power source to try and ensure its all in one piece.
A cheap display to put on to ensure the problem is not your existing display would be the DZ40. You can get them for as little as $25 on Amazon, Ebay or AliExpress. They're my personal favorite as a minimalist display. The cheap cost is a bonus but not the reason I use them.