Most internet search engines work based on similar methods. They help you search the web based on important words, so called 'keywords". Whereas it would be really cool if you could search every single page stored on every single server connected to the internet, it's simply not possible to date. This is because search engines comb through an index they keep of a certain amount of available pages. The number of available pages within every search engine's index may be as high as hundreds of millions of web pages, but it's certainly not complete.
But let's move on to the actual search. If you type your question or the term you are looking for, the so called 'search query', into your search engine's search bar and submit it, the search engine will then crawl through its index to look for the most suitable answers to your question. This process of looking for relevant answers is based on of course the certain keywords and on how often and in which order and context they are used on the web page the crawler has found. But there are many more factors: When was the web page containing the specific keywords published? Content that is up to date may be rated as more relevant for certain searches. When it comes to establishing a certain trustworthiness, older pages might seem more reliable. This brings us to the next question: Is the site trustworthy and reliable? An indicator for this might be how many other sites link to it. If something is highly recommended by various people, chances it is relevant and trustworthy are higher than if it's never referred to. Is it relevant to your location and language? If you have specified those factors in your search settings, they will have an effect on the search results you get. This piece of code responsible for finding information with certain properties (like language, relevance, etc.) is called search algorithm.
There are many more factors search engines are programmed to take into consideration when looking for answers to your questions. However, the way the results are presented is most likely always the same. The most relevant results for your search will be present at the top, followed by results deemed less relevant by the search algorithms your search engine runs on.
Most search engines show ads next to their search results. If a user clicks on one of these ads, the search engine is being paid for having directed the user to the advertiser's site. In Ecosia's case, at least 80% of profits from search ad revenue is used to support tree planting programs!
The field of search engines is a very complex one and it certainly hasn't been covered very profoundly here. We found this article on How Internet Search Engines Work pretty detailed and quite useful. So if you'd like to learn more, just give it a try.