A nameserver is simply a server that contains a directory of domain names that match a certain IP address (computer). The nameservers set on your domain will allow you to control which web hosting company controls your website and emails.
You will have records such as A records and MX records. The A record will define which servers your website is hosted on and the MX record will define where your emails are hosted.
How DNS works:
If you want to visit Google.com you will open a web browser and type google.com into the address bar.
Your computer then uses DNS to pull up the nameservers for google.com. Their nameservers are set to ns1.google.com and ns2.google.com.
Your computer will then ask googles nameservers for the A record Address for google.com.
The nameservers will then reply back with the IP address that is set as the A record 22.214.171.124.
your computer will send a request to that IP address along with the page you are requesting.
The server that is hosting google.com will then send your web browser the requested page.