Even though the main sometimes means the sea, the phrase 'in the main' has nothing to do with sailing. It has been around since the 1600s and just means 'for the most part'...ie much the same as the modern meaning of 'by and large'. Mainly and mostly are effectively synonymous.