HTTP is a stateless medium.
Which means a website doesn’t (can’t) remember what you did before on it. Each time you click a link it’s like the first time the website has ever seen you.
This makes it impossible to ‘sign in’ to a website.
The way they get around this is by dumping a small piece of code on your computer that says ‘hi website, it’s me and I have a proper account and am logged in’. That’s a cookie. And yes, websites need them to operate any kind of user experience.
So instead of a page that says ‘who the fuck are you?’ It can now retrieve the info from the cookie and show you the page that says ‘hi, KuromiGirl04, what’s happening? You’re all logged in and can access your account details or carry on from where you were before’.
Originally cookies could only be created, and then read back, by one website. So, eg, if you logged into your account on foobar.com, only foobar.com could read that cookie back.
But someone came up with the brilliant idea of third party cookies. So now, if you visit foobar.com you also (if you agree to it) get cookies created by facebork, grabble, aggressive-advertiser, the nra, the nsa, the kkk, and whoever else has convinced foobar.com that they get some value out of the deal.
That’s where the hundreds of cookies you need to scroll down and deny come from. Mostly advertisers or analytics, or advertisers, web optimisers, or advertisers…. And these third party cookies can be read anywhere by the company that sets them.
That way, when you visit shoefuckeringfreak.com facebork knows you’ve visited it and suddenly starts showing you sexy, sexy shoes on your facebork feed. And so forth.