Why do dogs walk around in a circle before lying down?

Circling is innate behaviour

The most probable reason why many dogs circle before they lie down is that their ancestors did so in the wild. You just can’t beat a good nights sleep and simply by circling  around in an area of grass would create a more level, softer surface for lying on. If the area was covered in snow or leaves, circling would similarly soften and level the spot.