Space is not flat. It is 3D, and we say that everything in it is held together on an imaginary surface we call spacetime. The idea of spacetime was put forward in Einstein's theory of relativity. When light travels through space, it moves along this surface. Mass, such as stars and galaxies, sitting on this surface makes it dip. Imagine a piece of material being held stretched out. If we put objects, like plates or heavy balls, on top of it, then the fabric would dip lower in those places. The same is true in space. Where we have mass, we get a dip in spacetime. The more massive the objects, the bigger the drop.
Now think about what would happen if you tried to roll a ball along the material loaded with objects making dips. If the ball gets too close to one of the objects, it will get stuck in the gravity well surrounding it. Or the ball might make it past the object, but its trajectory will bend slightly. The same thing happens to light moving past objects in space.
The most obvious bending of light comes when objects are lined up directly behind each other. But the more massive the object, the bigger the curve in spacetime. A cluster of galaxies makes a powerful lens. These galaxies don't just contain stars, gas, and dust; they are all held together in a giant halo of dark matter – adding to the mass. Images of lensed galaxies around these clusters have helped us find the dark matter and make a map of the Universe!
Lensing happens when light from directly behind a massive object, from our line of sight, can be bent around it. We call this gravitational lensing, and it is a way to see an example of the theory of relativity.
Gravitational lensing bends the light around the foreground object, making background objects look distorted, often like small arcs of light. If these arcs form most of a ring they are known as Einstein–Chwolson rings.
Lensing also magnifies the light coming from the background object. We can use it to see things that are usually too far away and faint to observe without the lens. This has let us observe the most distant galaxies ever seen.
We can sometimes see mini versions of this effect, known as gravitational microlensing when a nearby object magnifies a star. Because these stars are closer, they also appear to move across our skies more quickly, meaning we might only see each one for a few days a year. But the magnifying properties of these lenses have been able to help find exoplanets in our galaxy.