As I understand, the metric system starts with an arbitrary weight, and calls it $1\, \mathrm{kg}$, then the volume of this weight in water gives the meter. And then the energy is defined based on the meter, second and kilogram.

My question is: given that the relation between meter, kg and joule relies on the density of water (or did so originally), how can we possibly tie them again with $E=mc^2$ by adding the speed of light? The density of water seems completely uncorrelated to the speed of light.

Intuitively I would have added an extra constant to Einstein's equation.