Ahrefs looks at the backlinks of the top-ranking pages for a keyword to calculate difficulty. If those pages have lots of high-quality backlinks, the keyword is harder to rank for. It’s pretty reliable, but remember—it doesn’t consider other factors like content quality or user intent.