The main purpose of a web crawler is to discover and index web pages for search engines. They follow links, gather content, and create a searchable database of web pages to provide relevant results for user queries.