Regular 1.18 Aristois worked fine for me but when I added optifine in the addons marketplace and restarted it kept crashing and giving me exit code 0, I deleted the 3 .minecraft libraries components said in other 1.18 crash forum posts and that fixed it but no more optifine so I don't think they are currently compatible for some reason
However when I launch game now it gives me error 500 when i try and connect to realms
I can't help with the optifine issue unless I see a crash log. They are working when installed correctly.
Realm error is unrelated. I have confirmed that Realms are working, so try again on your end. It can take a little to load.