This is due to conservation of linear momentum.
Initially both were at the rest position so initial momentum is zero.
To conserve the momentum, when sailor jumps forward, boat moves in backward direction because momentum is vector quantity.
Finally magnitude of the sailor and the boat is same so they are moving in opposite direction , net final momentum is zero ,
so this proves the law of conservation of linear momentum.