Is it legal to use UE3?

The full UE3 engine is still under a commercial license with an upfront cost (like $300k minimum) to use, so you cannot download that for free and use it. As darthviper says there is a separate version of UE3 called UDK which uses a similar licensing model to UE4 (i.e. no upfront cost, you pay Epic a percentage of your game’s revenue).

The main difference is that with UDK you don’t get source code access to the engine and no formal support from Epic, but you get the tools (Unrealscript, Kismet and the editor) needed to make your game.