To understand how the lens works, you need to understand a little about how the light coming from an object behaves as the distance between the object and the eye changes. Let's consider 3 examples:
A. An object placed far away from the eye.
B. An object very close to the eye.
C. An object in between.
First, note that light reflected (or emitted) by a single point on the object moves outwards away from the object in a large cone. Part of this expanding cone of light is then captured by the cornea and pupil. So we can say that the light that is captured by the eye forms its own cone with a smaller angle than the larger cone, whose light goes everywhere else. In the image below, object O
1 corresponds to example A, object O
2 corresponds to example B, and object O is example C.
The dashed/solid lines coming from O
1, O
2, and O
3 represent the outermost light rays of our expanding cone that the eye captures. The key thing to notice is that the angle between the two extreme light rays of this cone
increases as the object gets closer to the eye. In other words, as the object gets closer, the light rays of the cone hit the cornea at an increasingly large angle as the object moves closer. If we imagine a single glass lens instead of the eye, then as the angle of these light rays increases, they get focused further and further back behind the lens. So an inflexible glass lens by itself only has a very small range of object distances where it can bring the light down to a tight focus. Everything outside of that range would appear blurry. If you had this single lens and a camera sensor behind it, you would need to move the sensor or the lens back and forth to get objects at other distances in focus (which would make the objects previously in focus become blurry).
The problem here is that the cornea (the most external part of the eye, and the part which has most of the refractive power of the eye. The lens just does "fine focusing") is
not flexible and does not bend. Or, more accurately, it's flexible, it just doesn't have anything attached to it to bend it. This means that if we had no lens, or if our lens was inflexible, we would have only a small range of distances wherein objects would be in focus. Luckily for us, our lens is flexible and is attached to muscles which cause it to change shape when flexed. When you focus on an object at a closer distance, such as O
2 in the image below, the muscles in your eye flex and bend the lens so that it is more strongly curved and has more power. This increased power brings the light rays from O
2 (the short dashed lines) to focus closer to the lens. Ideally, it brings them to focus on the retina itself.
However, the light rays from objects further away, represented by O
1 in the picture, are then brought to focus
before they hit the retina. This is why objects far away look blurry when you focus up close.
If you then shift to look at O
1, the muscles in your eye relax and your lens goes back to its original shape and becomes less strongly curved. The light rays aren't bent as much and now the rays from O
1 come to focus on your retina and the rays from O
2 are focused behind the retina (or would be if they weren't absorbed by the retina first). Hence, objects up close look blurry when you focus into the distance.
If you then focus on object O, then both far away objects nearby objects look blurry. This is what is being shown in the image below. The rays from O are focused onto the retina, while the rays from O
1 come to focus before the retina and the rays from O
2 are brought to focus behind the retina.