Which courses from a math department would cover quaternions? The subject of quaternions is often taught in engineering and physics courses due to its applications in 3D rotations and quantum mechanics. This treatment is often superficial and only presented as a tool. I would like to learn about quaternions in context within mathematics. I would guess that quaternions are covered in some sort of advanced algebra course.
How and where does the subject of quaternions fit into the greater story of mathematics and which courses would be likely to cover this material?
 A: You ask

How and where does the subject of quaternions fit into the greater
  story of mathematics and which courses would be likely to cover this
  material?

For the first part of your question, start at the wikipedia entry on the history of the quaternions and other links offered by that search.
In answer to the second part, you are unlikely to find much coverage in any mathematics course these days - just occasional mention as examples.
Their resurgence was prompted by their efficiency at encoding three dimensional rotations for computer graphics applications, so you have to search that literature, perhaps starting from wikipedia: https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation .
A: I will write a short answer, that will hopefully help you with part of your post, namely the link between the quaternions and rotations.
Let $q$ denote a unit quaternion. Identify the imaginary quaternions with $\mathbb{R}^3$, and let $x$ be an imaginary quaternion.
One can define an action of the group of unit quaternions, denoted by $Sp(1)$, on $\mathbb{R}^3$, via the formula
$$(q,x) \to qx\bar{q}$$
using quaternion multiplication, where $\bar{q}$ is the quaternionic conjugate of $q$. For a fixed $q$, the map $f_q$ from $\mathbb{R}^3$ to itself defined by
$$f_q(x) = qx\bar{q}$$
is a rotation in $\mathbb{R}^3$ with respect to an axis passing through the origin. The group of all such rotations in $\mathbb{R}^3$ is denoted by $SO(3)$. The map from $Sp(1)$ to $SO(3)$ mapping $q$ to $f_q$ is a $2$-to-$1$ surjective group homomorphism with kernel $\pm 1$.
Quaternions can make some formulas more compact. There is also a nice interplay between quaternionic geometry and complex geometry exemplified by twistor theory. Many moduli spaces in mathematical physics have a natural quaternionic geometry on them.
A: For an introduction in a context other than algebra, there's a nice (to some of us!) section of Steenrod's book on Fiber Bundles, but it has several disadvantages unless you're (approximately) in your first year of a mathematics graduate program: somewhat old-style language and notation, a rather dense writing style (each sentence make take a half-page of your own notes to work out details), and a pecuiliar sense of what makes them interesting --- you won't see anything about dynamics in physics, etc. 
Still, I like it a lot, and it was my knowledge from Steenrod that I put to use when I wrote about quaternions for the book Computer Graphics, Principles and Practice, 3rd edition. 
BTW, if you can find a turn-of-the-century copy of Maxwell's Treatise on Electricity and Magnetism, you can read the most baffling verbiage imaginable about quaternions, further complicated by Maxwell's use of Fraktur fonts. When you see a sentence that begins something like "The vector part of a vector is distinct from its real part,...", you know you're in for a bumpy ride. On the other hand, encoding the (negative) electric potential as the real part of a quaternion and the electric field as the "imaginary" part, and similarly for the magnetic stuff (although there's not a lot of magnetic "potential" around, I believe) makes Maxwell's four equations become just two, which is kinda fun, if you're a glutton for that kind of punishment. 
