The ciliary muscles adjust the shape of the lens, making it thicker for nearby objects and thinner for distant objects, allowing the eye to focus light properly on the retina.