  We study the structural phase transition, originally associated with the
highest superconducting critical temperature $T_c$ measured in high-pressure
sulfur hydride. A quantitative description of its pressure dependence has been
elusive for any \emph{ab initio} theory attempted so far, raising questions on
the actual mechanism leading to the maximum of $T_c$. Here, we estimate the
critical pressure of the hydrogen bond symmetrization in the Im$\bar{3}$m
structure, by combining density functional theory and quantum Monte Carlo
simulations for electrons with path integral molecular dynamics for quantum
nuclei. We find that the $T_c$ maximum corresponds to pressures where local
dipole moments dynamically form on the hydrogen sites, as precursors of the
ferroelectric Im$\bar{3}$m-R3m transition, happening at lower pressures. For
comparison, we also apply the self-consistent harmonic approximation, whose
ferroelectric critical pressure lies in between the ferroelectric transition
estimated by path integral molecular dynamics and the local dipole formation.
Nuclear quantum effects play a major role in a significant reduction ($\approx$
50 GPa) of the classical ferroelectric transition pressure at 200K and in a
large isotope shift ($\approx$ 25 GPa) upon hydrogen-to-deuterium substitution
of the local dipole formation pressure, in agreement with the corresponding
change in the $T_c$ maximum location.
