The game works fine without optifine but with it, the game crashes.
Your settings are glitched. Delete optionsof.txt or change your 'Max FPS/ Render Distance" settings and restart.
@dyiing Worked with just that fix. Thank you for being a real one and helping all these people including me!