Is it illegal to download games online?

It depends entirely on where you're downloading from. Legitimate storefronts and official free releases are fine; unauthorised copies of commercial games are not.

The practical rule is simple — if a site looks shady, it probably is, both legally and in terms of what's bundled with the download.