Hosts File maps domain names to IP addresses. Back in the early days of the Internet, there was no Domain Name System and people kept the IP Address and domain name in a file called hosts. It is simple text file that maps the name of the website to the IP address.
Typically, when making a web request your computer will check this file and if no entry exists it will query a DNS server, to find the IP Address for a certain website. Your ISP will assign you a DNS server which they control and can log and record your activities.
A DNS server simply finds and translates the name into the IP Address so that your machine can route and connect your device to the website you are searching for. A hosts file can speed up performance, block known ad/spyware/malicious websites before your browser even sends an HTTP request.
A curated and compiled list of hosts files are useful for fending off these bad websites. Beware, some websites you go to might be blocked, so read through a file to see what is allowed or not.