History of dot product and cosine The fact that the dot product and the cosine of the angle between two vectors are mutually computable is easy to show (see the two sides in the two answers at Dot product in coordinates).
But looking at the dot product, I would never have thought that it somehow captures something about the angle (and vice versa).
How did the connection get discovered? Who were the major players? Did it just fall out of the development of matrix operations for linear algebra (or did the dot product come first) or are these only related by hindsight or what?
 A: Looking at mathword under D you'll find:

DOT PRODUCT is found in 1901 in Vector Analysis by J. Willard Gibbs and Edwin Bidwell Wilson:
The direct product is denoted by writing the two vectors with a dot between them as
A·B
This is read A dot B and therefore may often be called the dot product instead of the direct product.
[This citation was provided by Joanne M. Despres of Merriam-Webster Inc.] 

If you get a hold of a copy I'm sure they'll have a good discussion on the matter.  Gibbs was the big proponent of vectors and I'm willing to bet he'd have discussed the connection between the two.  That'd probably be a good starting point to tracking down an answer to your question.
A: Cross-posted my answer here.
It is Sir William R. Hamilton who originally touched upon the concept. Near the end of his letter to John T. Graves about his recent discovery of quaternions in the same year (1843), he writes the following:

Multiplication will be easy if we are familiar with the rules for the product of two pure imaginaries. This product is, by (B.),
$$(0, b, c, d)(0, b′, c′, d′) = (−bb′ − cc′ − dd′, cd′ − dc′, db′ − bd′, bc′ − cb′);$$
the product-line is perpendicular to the plane of the factors; its length is the product of their lengths multiplied by the sine of the angle between them: and the real part of the product, with its sign changed, is the same product of the lengths of the factors multiplied by the cosine of their inclination.

In essence, he recognized that (using modern notation for quaternions):
$$(0, \vec{v})(0, \vec{w}) = (-\Vert \vec{v} \Vert \Vert \vec{w} \Vert \cos(\theta), \Vert \vec{v} \Vert \Vert \vec{w} \Vert \sin(\theta) \vec{k})$$
where $\theta$ is the angle between $\vec{v}$ and $\vec{w}$, and $\vec{k}$ is perpendicular to $\vec{v}$ and $\vec{w}$.
This discovery precedes Gibbs and Heaviside, who were born in 1839 and 1850 respectively.
A: I suspect that J.M. is right: historically, quaternions came before vectors.  But before the quaternions you had complex numbers.
For two complex numbers $z$ and $w$, the fact that $\text{Re}(\overline{z} w) = |z| |w| \cos \theta$, where $\theta$ is the angle between them measured at the origin, is clear from the polar representation.  Write this out in terms of the real and imaginary parts of $z$ and $w$ and you have the two-dimensional version of your relationship.   
Hamilton, of course, knew all of this, and a main motivation behind his development of the algebra of quaternions was to get a way to study three-dimensional space analogous to the use of complex numbers to study two-dimensional space.  If $P = a i + b j + c k$ and $Q = d i + e j + f k$ are quaternions representing what we would call "vectors", the real part of the quaternion $\overline{P} Q = (-ai-bj-ck)(di+ej+fk)$ is $ad + be + cf$, and this 
should be (and is) $|P| |Q| \cos \theta$.
Gibbs et al dispensed with the quaternion framework and wrote this as the "dot product" of the two vectors $(a,b,c)$ and $(d,e,f)$. 
