The metacentre, or centre of buoyancy, is the centre of gravity of the volume of water which the hull displaces. When a ship is upright, the metacentre is directly above the centre of gravity of the ship.
The distance between them is called the metacentric height, and is usually between one and two metres. As the ship heels over, the centre of gravity remains fixed with respect to the ship because it just depends upon the ship's construction and cargo, but the profile of the volume of water displaced by the hull changes. The metacentre moves sideways in the direction in which the ship has rolled and is no longer directly under the centre of gravity.
The righting force on the ship is then caused by gravity pulling down on the hull, effectively acting on its centre of gravity and the bouyancy pushing the hull upwards; effectively acting on the metacentre. This create a torque which rotates the hull upright again and is proportional to the horizontal distance between the centre of gravity and the metacentre. The metacentric height is important because the righting force is proportional to the metacentric height times the sine of the angle of heel.
A ship with a small GM will be "tender" - have long roll period - and if it is too small will be at risk of capsizing in rough weather. This was the cause of the loss of HMS Captain in 1870. If a ship is damaged and partially flooded one effect is to reduce the metacentric height and make it less stable. A larger metacentric height on the other hand gives a ship a short roll period and good stability, but if it is too large the ship is "stiff" - uncomfortable for passengers because it quickly jumps back upright after a wave or wind gust which heeled it over has passed.
There is also a similar consideration in the movement of the metacentre forward and aft as a ship pitches.
The abbreviation GM is used because the centre of gravity is usually given the symbol G and the metacentre M.
See: Naval architecture