Close the game and launcher.
Download OptiFabric and place it in the directory .minecraft\libraries\me\deftware\EMC-F-v2\latest-1.17.
Download OptiFine (1.17) and place it in the directory .minecraft\mods.
Start the game, and OptiFine is added.
If you crash on startup, you probably forgot to place OptiFine in the mods folder. If you are on MultiMC, the directory in step 2 is MultiMC\libraries\...
⚠ OptiFine is not in the addons marketplace for a reason. It causes many bugs with render mods and they will stop working completely. Adding OptiFine manually means that you are doing so at your own risk and you acknowledge any bugs or issues that can happen. ⚠