How does the litmus pH indicator work?
This explanation is true for most organic indicators.  Litmus is a complex mixture of organic molecules.  The molecule responsible for the color change (the chromophore), is 7-hydroxyphenoxazone (image taken from Wikipedia, public domain):



See that $\ce{OH}$ group at the lower left?  That's where the so-called "acidic proton" is.  This molecule is actually a weak acid, meaning that in the presence of a strong base, the $\ce{OH}$ group can lose a proton, which reacts with an hydroxide ion ($\ce{OH^{-}}$) to form a water.  The 7-hydroxyphenoxazone is now a negatively charged ion: it looks the same except it is missing the $\ce{H}$ on the $\ce{OH}$ group, and it leaves behind an electron.

To think about the equation that describes what's going on, pretend that the entire 7-hydroxyphenoxazone molecule is represented by the formula $HLit$, where $\ce{H}$ is the hydrogen on the $\ce{OH}$ group and $Lit$ is everything else (this is common procedure: only the hydrogen matters in the acid-base equation).  Then the acid-base equation is:

$$\ce{OH^{-} + HLit &lt;=&gt;H2O + Lit^{-}}$$

As more strong base is added, more hydroxide ion is present, driving the equilibrium to the right and producing more $Lit^-$ ion.  And now, the color change: $HLit$ is red, but $Lit^-$ is bue.  So the more acidic your solution, the more the equilibrium is to the left and thus there is more $HLit$ than $Lit^-$.

Litmus is pretty good for checking rough acidity or basicity, because its midpoint pH is close to 7 (neutral).  Litmus is as red as it gets at a pH of 4.5, and is as blue as it gets at a pH of 8.3, so the midpoint is about 6.4, a bit more acidic than pure water.