Canonical URL tell search engine to be clear that to point to the reference url (unique), to avoid duplicate content. If the same content can be access with multiple url then choose the prefer version and put the canonical in other pages to let search engine know only the canonical version to be in index.
Consolidating link signals for the duplicate or similar content
It helps search engines to be able to consolidate the information they have for the individual URLs (such as links to them) on a single, preferred URL. This means that links from other sites to http://example.com/dresses/cocktail?gclid=ABCD get consolidated with links to https://www.example.com/dresses/green/greendress.html.
Tracking metrics for a single product/topic
With a variety of URLs, it's more challenging to get consolidated metrics for a specific piece of content.
Determining the URL you want people to see
You prefer people reach your green dresses product page via https://www.example.com/dresses/green/greendress.html rather than https://example.com/dresses/cocktail?gclid=ABCD.