Why don't spawn chunks work properly with OptiFine?
The Smooth World option in the Optifine performance settings allows spawn chunks to unload when you are faraway. If you want iron farms to keep working as long as you are in the overworld, turn Smooth World OFF.