Matching is cheap; ordering is the product
A query for "tomato soup recipe" against a big corpus might match two hundred thousand documents. Nobody reads two hundred thousand results; almost everybody reads ten. The entire commercial value of a search engine is concentrated in which ten float to the top.
That is scoring's job: assign every matching document a number expressing how well it satisfies this query, and sort. The score does not need to be meaningful in absolute terms, and is not, BM25 scores are unbounded and incomparable across queries, it only needs to order documents well.
The modern default, BM25, comes from the probabilistic retrieval tradition developed by Stephen Robertson, Karen Sparck Jones and colleagues, the Okapi BM25 line of work, and became Lucene's default scoring function, which makes it the out-of-the-box ranking of Elasticsearch, OpenSearch and Solr.
Key idea: BM25 is three intuitions with algebra attached: terms that are rare in the corpus carry more information; a term appearing repeatedly in a document matters more, but with sharply diminishing returns; and matches in long documents count for less than matches in short ones. Learn the three and the formula assembles itself.

