There are times when you want to access machines on LAN or internet using the IP address. Hosts files in various systems can help you auto redirect logical names to the IP address. For example
Now whenever you will call mysite.com, you will be pointing to localhost. Similarly you can use any IP address on LAN or Internet and redirect logical names to them.
More on usage of hosts file : en.wikipedia.org/wiki/Hosts_(file)