There are better battery experts on this forum than me, but I'll start by asking if either one is a Deep-cycle battery?  That would make sense for the stereo.  And which ever has the highest Cold Cranking Amps (CCA) would be best for starting the engine.
I wouldn't be surprised if your boat was set up with the group 27 as a starting battery and the group 31 as a deep cycle battery, but check the labels and see.
					
						_________________

"Knot Easy" 2000 Horizon 240 Volvo 5.7GS /SX
  tow: 2017 Honda PILOT EXL-AWD
  prev. boats:
'87 Chaparral 198CXL 4.3 OMC Cobra
'69 Jetstar 16ft Ski Boat, 115hp Yamaha
'68 Aluminum Jon Boat, 3hp Sears
'64 Water Wings