Just like a few other people I get the Error Code: 0 crash when trying to launch the game with the forge profile with mods. Specifically the OptiFine (extracted Mod-version).
Running Forge without it works. Running the separate OptiFine (not extracted mod-)version without Forge works as well. But together makes it crash a second after I click the Launch button without the red loading screen.
Here an overview on what I have and tried:
I'm running the latest Forge version. OptiFine is also the latest, matching version. Java is up to date as well.
There are no other mods, shaders or similar installed (right now since they need updates).
I tried it on my old updated Minecraft launcher version and a completely fresh re-install of everything.
I downgraded to 1.16.5 to see if I made a mistake when installing either, but with these version it worked.
I assumed that maybe Forge has a problem with mods in general so I removed OptiFine and installed a different one (in this case Inventory HUD+). Yes, they are completely different and have nothing in common, but I just wanted to be sure on that part. This mod worked fine with Forge.
Haven't tested it with any more mods since a lot need to be updated for 1.17 Forge so I can't tell if mods more similar to OptiFine have the same issues.
Concluding this I'm actually not sure if the problem lies with Forge, OptiFine or if the communication between both is off. I also haven't seen any error reports on their side so far but that doesn't mean much.
debug log from the logs-folder: https://pastebin.com/i9kUDk9x
log from the game launcher: https://pastebin.com/8W8C1kvn
Thank you for any help