Representing rotations via Euler angles can lead to gimbal lock[0], whereas using quaternions doesn't. The best explanation I could find quickly is this one:
euler angles are sort of the odd one out, a particularly bad way to represent rotations. Orthonormal matrices, quaternions, skew-symmetric tensors with exponential map -- all represent SO(3) without gimbal lock, with different pros and cons for each.
https://mathoverflow.net/a/95908
[0] https://en.wikipedia.org/wiki/Gimbal_lock#In_applied_mathema...