For centuries it was believed that the pupil of the eye was solid and spherical like an apple, so that’s what they called it.
Therefore, anything or anyone compared to it would indeed be very special.
In the Bible, the expression is part of a song spoken by Moses:
“He found him in a desert land, and in the howling waste of the wilderness; he encircled him, he cared for him, and kept him as the apple of his eye.”
These days, we still say that something special is “The Apple of Your Eye”.
The original Hebrew for the idiom was ‘iyshown ‘ayin (אישון עין), which is literally translated as “Little Man of the Eye.”