A cookie is a small file a website stores on your device through your browser. On your next visit the browser sends it back, so the site can remember something: that you're logged in, which language you want, what's in your basket.
That's the useful side. The other side is that the same mechanism can follow your behaviour across sites and build a profile of you. Hence the legislation.