  Let $\mathsf{F}_r$ be a free group of rank $r$, $\mathbb{F}_q$ a finite field
of order q, and let $\mathrm{SL}_n(\mathbb{F}_q)$ act on
$\mathrm{Hom}(\mathsf{F}_r, \mathrm{SL}_n(\mathbb{F}_q))$ by conjugation. We
describe a general algorithm to determine the cardinality of the set of orbits
$\mathrm{Hom}(\mathsf{F}_r,
\mathrm{SL}_n(\mathbb{F}_q))/\mathrm{SL}_n(\mathbb{F}_q)$. Our first main
theorem is the implementation of this algorithm in the case $n=2$. As an
application, we determine the $E$-polynomial of the character variety
$\mathrm{Hom}(\mathsf{F}_r,
\mathrm{SL}_2(\mathbb{C}))//!/\mathrm{SL}_2(\mathbb{C})$, and of its smooth and
singular locus. Thus we determine the Euler characteristic of these spaces.
