It is used to keep crawlers from wasting time on useless pages (internal search, filters, admin area) and to indicate the location of the sitemap.
Note: blocking a page in robots.txt does not necessarily prevent it from being indexed, and mistakenly blocking AI crawlers (OAI-SearchBot, PerplexityBot…) can stop your site from being cited in their answers.