Ab initio investigation of electronic and vibrational contributions to linear and nonlinear dielectric properties of ice