For a very long time, large structures were made of masonry: brick and stone and concrete. Masonry is strong when you’re squeezing it (putting it under compression). It is not strong under when it’s being pulled (placed under tension). This is a problem for building roofs. Consider a horizontal beam made out of masonry. Gravity is pulling down on the whole beam, but the ends are supported. So the tendency would be for the middle to droop down – which puts the masonry under tension.
The arch is the one weird trick to solve that problem. The shape of the arch means the higher bricks (say) push on the lower bricks – which is the kind of compression bricks can take. At the legs of the arch, all that weight producews a force pushing down and to the side. If the arch is fastened to the something big, like the earth, that force won’t have an effect, because the earth can push back just as hard.
The roof of a cathedral is essentially a bunch of arches resting on walls. Those walls have to resist the downward force – which is easy, compression again – and also the outward force that is trying to topple the wall over. The higher the walls, the easier it would for the roof to topple them over, and cathedral builders wanted ever higher walls and ever wider (that is, heavier) roofs.
One solution would be to make the walls really thick so they could resist the sideways force. Alternately, you could make the wall thick only where the arches of the roof rest, which is where it matters. That’s a buttress: essentially a big pile of rocks pressing against the side of the wall to help support it against the force of the arch (to keep it in compression because it's being pushed from both sides).
But for the kind of cathedrals people wanted, such buttresses would have to be big and ugly and expensive.
The buttress part of a flying buttress is smaller and – importantly – shorter than a regular buttress and placed away from the wall. The wall is connected to the buttress by an arch, which transfers the outward force on the wall down to the buttress. But, because the buttress is lower down, there’s a shorter lever arm, so the small buttress can be just as hard to push over as a larger one directly against the wall.
The arches make flying buttresses look prettier than regular buttresses. And since they're not up against the wall, there's more room for windows and less masonry blocking their view, so Gothic cathedrals could achieve their characteristic spacious look.
I took this mostly from "How Flying Buttresses Work". Any errors are my fault.