Like many other really weird things cats do, science hasn’t fully cracked this particular feline mystery. There’s the obvious predation advantage a box affords: Cats are ambush predators, and boxes provide great hiding places to stalk prey from (and retreat to). But there’s clearly more going on here.
…
rather than work things out, cats are more inclined to simply run away from their problems or avoid them altogether. A box, in this sense, can often represent a safe zone, a place where sources of anxiety, hostility, and unwanted attention simply disappear.
…
According to a 2006 study by the National Research Council, the thermoneutral zone for a domestic cat is 86 to 97 degrees Fahrenheit. That’s the range of temperatures in which cats are “comfortable” and don’t have to generate extra heat to keep warm or expend metabolic energy on cooling. That range also happens to be 20 degrees higher than ours,

Cardboard is a great insulator and the small space can warm up above the room temperature.

Of course these explanations don’t answer why cats like to site inside tape outlines on the floor.

Research is wonderful but cats often seem to be so far beyond our beyond our ability to understand we are left to just love them. It is enough to know that your cats will love the boxes you give them and tape outlines you draw on the floor – unless, of course, they don’t.