This image shows two ways you might reach a given website’s home page. Each one is a different URL.
If your website accepts both, search engines may be unsure as to which URL is the correct one to index. They may index both of them. This is serious because it splits your ranking in half. Google will look at your website as if it is two separate websites, not one.
Correcting this problem should only be done only by a qualified webmaster. Attempting to fix the problem incorrectly could shut down your entire website. You may choose having the www or not having it as your preference. It doesn’t really matter which.
After the problem is corrected, your website will behave differently. Let’s say you prefer having your pages served with www before your domain name. If a request comes to the server without the “www.” part, whoever is requesting the page (Google, or perhaps a browser) receives a directive that says No- that page does not live here- however you can have the page starting with “www.”
As a result, Google learns that all the pages on your website should include “www.” and it gives full credit to all requests made thereafter. Instead of seeing your website as two separate websites competing with each other, it sees them as one.