Quaternions don't really capture the full structure of 3d space, but one can abuse the mathematical properties of it to hack the system and get a solution.
Geometric algebra is a system that subsumes quaternions in a straightforward way. To do this, it uses a "geometric product" of basis vectors, which is written by juxtaposition:
Under the geometric product:
$e_i e_j = \begin{cases} 1, & i = j \\ -e_j e_i, & i \neq j\end{cases}$
The geometric product is associative, and this allows one to build chains of such products in an unambiguous way. For example, $e_1 e_2 e_1 e_3 e_1 = -e_2 e_3 e_1$ (just switch the first $e_1$ with $e_2$ at the cost of a minus sign).
How does this connect with rotations and quaternions? Bear with me. We can use the geometric product to build linear operators. One such linear operator is the reflection:
$\underline N(v) = -e_1 v {e_1}^{-1}$
The effect of this linear operator is to take the $e_1$ component of any vector and negate it. This is a reflection.
Chaining two separate reflections together allows us to build up a rotation. This is because while a single reflection is not orientation preserving (it has determinant $-1$), two of them put together will have determinant $+1$. Let's consider another reflection that changes the $(e_1+e_2)/\sqrt{2}$ component. The result is
$\underline R(v) = \frac{e_1 + e_2}{\sqrt{2}} e_1 v e_1 \frac{e_1 + e_2}{\sqrt{2}} = \frac{1}{2}(1 + e_1 e_2) v (1 - e_1 e_2)$
This describes a particular rotation. The quantity $(1 + e_1 e_2)/\sqrt{2}$ is called a spinor or rotor, and $(1-e_1 e_2)/\sqrt{2}$ is its multiplicative inverse.
In general, though, a spinor or rotor can take the following form:
$q = a + b e_1 e_2 + c e_2 e_3 + d e_3 e_1$
which allows us to write any general rotation as
$\underline R(v) = q v q^{-1}$
This is the basic idea of quaternions, but instead of an abstract mathematical field, we have derived the form of rotations geometrically, built from reflections. The rotors themselves are linear combinations of scalars and "bivectors", which represent oriented planes in 3d space.
Now, why does using a "pure" quaternion for $v$ give us rotations of vectors? Well, the rotation operator I have described works for pure bivectors (which correspond to pure quaternions), so we can set $a=0$ for $v$ and carry out the proper multiplications. The result will then be
$\underline R(v) = \underline R(b e_1 e_2 + c e_2 e_3 + d e_3 e_1) = f e_1 e_2 + g e_2 e_3 + h e_3 e_1$
for some numbers $f, g, h$. One then converts this back to a vector through duality, multiplying on the left or right by $e_1 e_2 e_3$, which we call $i$. The result is
$(e_1 e_2 e_3) (f e_1 e_2 + g e_2 e_3 + h e_3 e_1) = f e_3 + g e_1 + h e_2$
This converts the result back to a vector. But the nice thing about geometric algebra is that you don't have to do this hijinks of going back and forth between vectors and bivectors. The rotation operator actually works on vectors--and moreover, this entire approach to rotations works in dimensions other than 3! This generalizes how we use complex exponentials in 2d, and you can use it in 4d to describe rotations, too. This is why I consider the GA approach to be far superior to quaternions, and far easier to connect the concepts to geometric interpretations.