Optometrist here. Don’t know where you heard this from, but they eyes do not have a separate immune system. The vasculature of the eyes is connected to the vasculature of the rest of the body and the same immune cells active in the rest of the body can be activated to battle infections in the eyes just like they do in the rest of the body.
There may be a bit of a misunderstanding in that there is a blood-brain barrier separating the blood from brain tissue and a similar barrier exists in the retina. Retinal tissue is similar neural tissue to brain tissue. Because the inside of the eye is fairly “isolated” from sources of infection, it’s rare for there to be an infection inside the eyes (although they do sometimes happen). And because of this, it’s pretty hard for your immune system to access the inside of the eye to fight the infection.
Add to this that the cornea, itself, is avascular (but can still have an immune response).
But the basis of your question is wrong. The eye does not have a “separate immune system” and your immune system will not treat the eye like a virus and attack it.
Latest Answers