The compass swing is carried out to minimise the difference between compass heading and magnetic heading (deviation).