It can tuck in its arms and legs when it rests; during that time, it slightly sways.
~Quote from Bulbapedia
This basically means that when it retracts its arms and legs, it is probably resting. If you read more from the Bulbapedia Link, Darumaka has a burning flame in its body. When the flame shrinks, it falls asleep and, thus, it curls up into a ball shape.
Source: Above Link
Hope I helped!