Lightning is unpredictable, but still follows the laws of physics. If you can provide a good straight low resistance path to ground there is a good chance this is where the pulse will go.
This prevents the most severe damage which can occur when the energy exits the hull via a metal fitting such a seacock or chainplate. In the former case the reasonable chance the boat will sink in the later that the mast will fall down.

Grounding is not a guarantee that this is where the energy will go, but with a well made ground system it there is a very good chance that is where all, or most of the energy will be diverted to.

Grounding is best defence you have. It significantly reduces damage, particularly the severe damage that can mean loss of the vessel and / or lives.

However it does not:
Significantly reduce the chance of a strike
Mean you will have no damage
Guarantee you won't suffer severe damage.