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.
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