The ending explained to non film nerds ... so spoilers dear reader
The wife says he lives on the boat. The end confirms he also dies there.
He sees Tobin as a son figure to him. So he rescues him and gives him the wealth to cope with womens needs that he blames the divorce on, rightfully or not. Tobin however would have preferred the new father figure alive.
Law's character may just have hoped that getting the gold would win back his wife.
MacDonald stashes Russians and British - for once - together in a submarine, and politically incorrect to present Western views, lets Law perform the psychology of solidarity ending with one of each nationality saved.