Optifine is quite safe and secure if the installation process is carried out smoothly. However, you need to be careful with the ads and popups which might carry some viruses.