Three things happen during baking that change the flavor of a cookie.
Maillard reaction, caramelization, and the melting of fats. There are more, but those are the three we're going to talk about.
The maillard reaction takes raw flour and turns it brown. It absorbs some of the sugar in the process, and creates a more complex, nutty flavor. Caramelization also browns some of the sugar, giving it a smoky, bitter flavor. They also give the cookie a firm or crispy texture.
You also melt any fats, like butter, that are in the dough. Melted butter separates and spreads throughout the cookie.
There's also often an egg that helps build structure for the baked dough, and sometimes baking soda for fluffiness.
This means uncooked dough is sweeter than a baked cookie. It has a soft, dense, and moist texture that disappears when fully baked. It's butter and sugar held together with flour and egg, and it's delicious.