Compression damping is a way of changing the effective spring stiffness depending on the speed of movement of the fork. If you have, say 100mm travel on your fork, you ideally want that 100mm to be just used fully whenever you hit a bump over 100mm high – eg so that the fork doesn’t bottom out harshly.
Compression damping allows you to use a softer spring (so you retain good small bump compliance and sag) which is then effectively stiffened up by the compression damping which is speed related (eg hit something faster/harder, the spring is effectively stiffer). As above, you want to use as little comp damping but enough to avoid harsh bottoming.
So, if for example your riding had lots of steps/drops, you may well use more compression damping to avoid bottoming out on those rather than just fitting a harder spring which would make everything harsher.