Cookies were invented by Netscape and have long been an integral part of the internet.
Cookies try to address the fundamental "problem" that webpages do not have memory, yet could improve your experience by remembering how you have interacted with them.
Cookies can for example hold preferences you have selected on the website so that you do not have to reset these preferences each time you visit the site.
A cookie may save your username if you select the "Remember Me" box presented by many websites that require you to log in.
Other websites will use cookies to try to personalise your experience of their website by changing how it is presented according to how you have browsed their website previously.
If a website contains adverts then the companies that have placed those adverts may also store cookies on your computer.