A variational interpretation of the Biot-Savart operator and the helicity of a bounded domain