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".)
With the complex numbers in hand, it's natural to wonder what other systems of numbers containing the real numbers one might have. Before constructing the quaternions, Hamilton tried in vain to construct a $3$-dimensional system; it turns out that this is impossible, and you can see a reproduction of Hamilton's own proof in this recent question: Why should I consider the components $j^2$ and $k^2$ to be $=-1$ in the search for quaternions?
In fact, if you require that your "number system" be a division algebra (over the real numbers), it turns out that there are just four such systems: the real numbers, the complex numbers, the quaternions, and the octonions, so each of these is quite special. John Baez' paper "The Octonions" is a superb starting place for exploring this circle of ideas.
(NB there are plenty of interesting "number systems containing the real numbers", i.e., finite-dimensional algebras over $\mathbb{R}$; in other words, division algebras are not the only interesting thing we can ask for.)
$\qquad\qquad\qquad\qquad\qquad$ What is the motivation for quaternions?
Hamilton knew that the complex numbers could be interpreted as points in a plane, and he was looking for a way to do the same for points in three-dimensional space. However, $[$he$]$ had been stuck on the problem of multiplication and division for a long time. He could not figure out how to calculate the quotient of the coordinates of two points in space.
$\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad$ — Quaternions: History
$\quad$ In $1843$, Hamilton knew that the complex numbers could be viewed as points in a plane and that they could be added and multiplied together using certain geometric operations. $~$ Hamilton sought to find a way to do the same for points in space. But $[$he$]$ had been stuck on defining the appropriate multiplication. According to a letter Hamilton wrote later to his son Archibald:
$\quad$ Every morning in the early part of October $1843$, on my coming down to breakfast, your brother William Edward and yourself used to ask me: "Well, Papa, can you multiply triples?" Whereto I was always obliged to reply, with a sad shake of the head, "No, I can only add and subtract them."
$\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad$ — History of Quaternions: Hamilton's Discovery