Serious Q: What is the fundamental difference between a legal and illegal e-bike. This largely is differentiated by the location but I don't know what illegal e-bike means.
E-Bikes are sold & regulated in "classes" (at least where I live in the US).
A class 1 e-bike is pedal-assist and stops assisting beyond 20mph (mine, for instance, tapers off starting probably around 15 mph).
A class 2 is the above, plus a throttle.
A class 3 is anything that assists over 20mph. The "basically motorcycle" set exists here.
In addition to the other answer you got. E-bikes are pedal assist, so illegal ones usually have throttles in addition to more powerful motors. This depends on the region though.
Maximum power output and maximum (assisted) speed are generally legislated. In the UK, an e-bike is up to 250 W and 25 kph. More than that, it would classify as a motorbike and you'd need a license (not particularly onerous). The bike itself is often built differently to accommodate the different power profile.
As a pedal cyclist, I feel that's a reasonably sensible limit as much faster than that you should be more experienced as a cyclist to control the bike and anticipate the conditions.