Critical role of magnetic moments on lattice dynamics in YBa${}_{2}$Cu${}_{3}$O${}_{6}$