What is the motivation for quaternions? I know imaginary numbers solve $x^2 +1=0$, but what is the motivation for quaternions?

Hamilton (and Graves) wanted to generalize $\mathbb C$ - if viewed as $\mathbb R^2$ with a multiplication that turns it into a field with a multiplicative absolute value.  They were looking for something similar in $\mathbb{R}^n$ for $n>2$.  It turns out that Hamilton spent 13 years in vain with $n=3$ although it was essentially known since Diophantus that what he was looking for was impossible.  He finally figured out that he could succeed for $n=4$ if he gave up commutativity.
(This is a short summary of chapter 20 of Stillwell's wonderful "Mathematics and Its History".)

