Navigate to http://optifine.net/downloads and find the appropriate Minecraft version you'd like to use, and download the latest iteration for that version. If you do not have a adblocker, we recommend one, like uBlock Origin; or at least a hefty dose of common sense, when downloading optifine, as some ads on the site can be fairly annoying in nature.
Run the Java executable
Change the Minecraft directory if needed and install
Open the Minecraft launcher, click the launch options tab, and select Optifine. This step is optional, but it is recommended to replace -Xmx1G with -Xmx4G or -Xmx2G to allocate either 4 or 2 gigabytes of RAM respectively
Select the News tab, click the green arrow besides the play button, and select optifine if it has not been selected already
Opening Minecraft and going into Options>Video settings should show the version of Optifine installed, Indicating Optifine has been installed correctly
Optifine has been injected into Minecraft and ready is for shaders/resource packs