How do I get the vanilla version of 1.12.2 into the versions folder for Optifine?
Open up Minecraft launcher, switch to the launch options tab, make a new profile (or use an existing profile if you know what you're doing), set the version to 1.12.2, click save. Then go back to the news tab, choose your new profile and run the game once.