This info helps determine your particular preferences.
Say you visit a website that sells ink cartridges. You register for an account. You buy a six pack of black ink. The site stores your information. The next time you visit they know who you are, what pages you visited, what kind of printer you have, and what products you might be interested in.
They are also used by companies with affiliate programs. Let's say you are an affiliate of the website that sells ink. Someone clicks on your ink ad. They are taken to the ink website. They buy ink. How does the ink website know that person was referred by you? Your tracking code is imbedded in a file. They usually expire anywhere from 60 to 90 days.
There isn't much cause to worry about this nowadays. Companies aren't allowed to dig for passwords and other important data that should be kept private. Some disreputable sites still try. Stricter site authentication and powerful software programs make it almost impossible for them to succeed.