Originally meaning the central aperture of the eye.
Figuratively it is something, or more usually someone, cherished above others.
The phrase is exceedingly old and first appears in Old English in a work attributed to King Aelfred (the Great) of Wessex, AD 885, entitled "Gregory's Pastoral Care".
The earliest recorded use in modern English is in Sir Walter Scott's Old Mortality, 1816:
"Poor Richard was to me as an eldest son, the apple of my eye."
It also appears in the Bible
Deuteronomy 32:10 (King James Version)
He found him in a desert land, and in the waste howling wilderness; he led him about, he instructed him, he kept him as the apple of his eye.
Он нашел его в пустыне, в степи печальной и дикой, ограждал его, смотрел за ним, хранил его, как зеницу ока Своего;
For thus saith the LORD of hosts; After the glory hath he sent me unto the nations which spoiled you: for he that toucheth you toucheth the apple of his eye.
Ибо так говорит Господь Саваоф: для славы Он послал Меня к народам, грабившим вас, ибо касающийся вас касается зеницы ока Его