If you’re using a newer version of Minecraft such as 1.15 or 1.16, you will need to click the ‘Preview Versions’ link found at the top of the page. Choose a Download link, ideally one that’s in bold.
It’s important that your Optifine version is the same as the Forge version (1.12.2 in my case). A new page will load, hit the Installer button, found under the ‘Download Recommended’ section. On the left hand side, you will see a list of Minecraft Versions, expand on the 1.12 section, then choose 1.12.2. Forge is free, and offers support for both Clients (single player) and Servers (multi-player).