A cookie is a small piece of information that the browser writes on the device (computer, mobile, tablet, smart screen, etc) of the user. There are first-party cookies or third-party cookies. First party cookies are the ones that belong directly to the website you are browsing. If you visit ebay.com, all the cookies hosted in ebay.com are first-party cookies. If you have a PayPal cookie on ebay.com, this cookie will be considered a third party cookie, as it´s outside the domain. The same happens with all the cookies that collect audiences, like DoubleClick, Adform, Google or Facebook, for example.
Cookies are very important for online advertising as they are one of the keys to all the systems. With the cookies, all the ad tech companies, like Facebook and Google, can identify the websites that one specific user sees and match with other data sources, like your logins. This information can be used then, by advertisers, to target users.
Cookies allow advertisers to cap the number of impressions/exposures per user and measure all the interactions per user. Cookies are then what allows advertisers to be more intelligent when they advertise in a programmatic way.