When unplugging a USB external hard drive, is it safer to unplug the cable from the computer, or from the external hard drive?
Since the USB cable is simply four wires with no active electronics, disconnection at either end is electrically the same result.
However mechanically the safer method is disconnecting the USB cable at the PC side, because you are likely to move/shake the drive while disconnecting at its end.
HDDs should be exposed to as little shock and vibration as possible, especially while powered on and spinning.
Even after unplugging the USB cable (and the HDD is powered off), the prudent action would be to give the HDD (especially if it's a 3.5" HDD) a few seconds to spin down and park the head assembly.
I am asking as I saw an EHD died right after the USB cable had been unplugged from it (the cable had been disconnected from the EHD first).
That may have been coincidence, or whatever shaking that the HDD got then was simply the "straw that broke the camel's back".
The drive failure after cable disconnect from the drive side could be of a simple electro-mechanical nature. The micro-USB3.0 connectors are pretty mechanically weak, especially in shroud/shield mounting area, while the cable overmold is usually very stiff. Moving out the cable might happen in a bending manner, and solder bonds between the connector pins and internal PCB might develop cracks, preventing the USB link from proper detection of Rx termination in one or another link direction. But this kind of failure usually develops over time, and signs of "connection flakiness" should be noticeable before the final failure.
Regarding electricals of disconnect from one or other end of a cable, unfortunately there are differences, but they would more likely cause a trouble with software end on the host, and unlikely kill the HDD.
In general, unplugging a cable (possibly in the middle of essential directory management operation) is called "surprise disconnect". Due to uncountable variety of conditions at the moment of disconnect, USB specifications do not regulate this event, and system protection and recovery is "implementation-specific". In other words, all bets are off with the surprise disconnect.