To understand a word in context, a model must decide which other words around it are relevant. Attention is the mechanism that lets each position look across the rest of the text and weigh how much every other word should influence it.
This is why modern models handle long-range relationships well, connecting a pronoun to a name many words earlier, for instance. It replaced older approaches that processed text strictly in order and struggled to carry meaning across long distances.