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.
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.
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.
In the United States, throttle-only ebikes that go up to 20 miles per hour (Class 2 ebikes) are legal pretty much everywhere. They're required to have functional pedals, but no pedal assist function is required.
Your class 3 definition is inaccurate. Class 3 is limited to 28mph and cannot have a throttle, only pedal assist.
Anything that doesn't fall in one of those classes is a motorcycle that is not street legal and can only be rudden of private property (unless you can convince your DMV to give you registration as a motor vehicle.)
This can vary somewhat from state to state, but most states have adopted or are moving to adopt these classes.