When a cookie bakes, the top hardens at some point. This happens in more or less time depending on the type of dough, how cold it is, oven temperature, etc. The amount of cracks also varies with each recipe. So, if the outer crust hardens before the cookie is fully cooked, the interior will still want to keep on expanding, and the batter will try to rise wherever it can, forcing the hardened crust to separate and crack.