Although this is an old question, this construction recently came up by reference in another question by Shaun, and it does not appear to be included above, so I figure I can add it (having checked with OP first).
Here's a categorical construction using products; it is actually related to the adjoint functor construction, in that it follows the ideas of Freyd's General Adjoint Functor Theorem. It can be carried out with any class of algebras that is closed under products and has a notion of "subobject generated". So it works in most "nice" categories of algebras (in the sense of Universal Algebra): abelian groups, $R$-modules, commutative rings, associative rings, etc.
Let $X$ be a set. A free group on $X$ is a pair $(F,u)$, where $F$ is a group, $u\colon X\to F$ is a set map, and the pair has a universal property: for every group $G$ and every set map $v\colon X\to G$, there exists a unique group homomorphism $\phi\colon F\to G$ such that $v = \phi\circ u$.
The idea is this: consider all pairs $(G_v,v)$ where $G_v$ is a group, and $v\colon X\to G_v$ is a set map. Take the product
$$P=\prod_{(G_v,v)} G_v,$$
of all such $G$, indexed by the pairs. The maps $v_G\colon X\to G$ induce a set map $u\colon X\to P$. Let $F$ be the subgroup of $P$ generated by $u(X)$. Then $F$ and $u$ will have the desired property, because given any group $G$ and set map $v\colon X\to G$, we obtain the relevant morphism $F\to G$ by simply taking the restriction of the projection $\pi_{(G_v,v)}\colon P\to G$ to the subgroup $F$. And because $F$ is generated by $u(X)$, this will provide the uniqueness. Voila! As if by magic, we obtain a group with the correct universal property.
However, there is a technical issue with the idea above: we can't construct that product, because the collection of all pairs $(G_v,v)$ is a proper class, not a set, and we cannot take a cartesian product indexed over a proper class. So we need to pare down this collection to something manageable (i.e., to a set).
The first observation we can make is that if $f\colon G\to H$ is an isomorphism, and $v\colon X\to G$ is a set map, then we do not need both $(G,v)$ and $(H,f\circ v)$ in our collection: we can just take $(G,v)$, and if we are presented with $H$ and $f\circ v$, we project to $G$ and then use $f$ to get all the way to $H$. So we really only need one group from each isomorphism class, plus all set maps from $X$ to that group (and that collection, for a fixed group $G$, is a set).
However, this is still not small enough, since there are groups of arbitrarily large cardinality, and thus even taking just one group from each isomorphism class we would still have a proper class. So we will not go down this road in the end (turns out to not matter).
The second observation to make is that in fact, given $(G,v)$, we don't really need all of $G$: we just need $\langle v(X)\rangle$, the subgroup generated by $v(X)$. Because the image of $F$ in $G$ will be generated by $v(X)$, so the image will lie inside that subgroup.
This is a good observation, because that bounds the size of generating sets we need to consider. And now we have an easy upper bound for how big the groups we need to consider are:
Lemma. Let $G$ be a group, and $S\subseteq G$ a subset of $G$. If $G=\langle S\rangle$, then $|G|\leq |S|\aleph_0$.
Proof. We know that $\langle S\rangle$ consists of finite products of elements of $S$ and their inverses. The set of such products has at most $|S|\aleph_0$ elements, so $G$ has at most that many elements. $\Box$
So, here's how we get around the technical issue: fix a set $M$ of cardinality $|X|\aleph_0$. We will consider all pairs $(G_v,v)$ such that
- $G_v$ is a group;
- $v\colon X\to G_v$ is a set map;
- $G_v$ is generated by $v(X)$;
- The underlying set of $G_v$ is contained in $M$;
Call the collection of all such pairs $\mathcal{S}$. It is now easy to verify that this is a set.
This is what is sometimes called a "solution set". It has the following property:
Given any group $K$ and set map $w\colon X\to K$ such that $K=\langle w(X)\rangle$, there exists a pair $(G_v,v)\in\mathcal{S}$ and an isomorphism $\phi\colon G_v\to K$ such that $w = \phi\circ v$.
So now we proceed as outlined above: Let $P$ be the product over all elements of $\mathcal{S}$,
$$P = \prod_{(G_v,v)\in \mathcal{S}} G_v.$$
Let $\pi_v\colon P\to G_v$ be the projection onto the $(G_v,v)$th coordinate. Because $\mathcal{S}$ is a set, this product exists and makes sense.
The underlying set of $P$ is the cartesian product of the $G_v$. Thus, the functions $v\colon X\to G_v$ induce a unique set map $u\colon X\to P$ such that $\pi_v\circ u = v$ for all $(G_v,v)\in\mathcal{S}$.
Now, we "remember" that $P$ is in fact a group, so let $F=\langle u(X)\rangle$ be the subgroup of $P$ generated by image of $u$. I claim that $(F,u)$ is the free group on $X$.
Indeed, let $H$ be any group, and let $w\colon X\to H$ be a set map. Then $K=\langle w(X)\rangle$ is a group generated by $w(X)$, and hence by the solution set property of $\mathscr{S}$, there exists a $(G_v,v)\in\mathcal{S}$ and an isomorphism $\phi\colon G_v\to K$ such that $w=\phi\circ v$. Let $\iota\colon K\to H$ be the inclusion map.
Then $\iota\circ\phi\circ\pi_v\colon F\to G_v\to K\hookrightarrow H$ is a morphism from $F$ to $H$, and
$$\begin{align*}
(\iota\circ\phi\circ\pi_v)\circ u &= \iota\circ\phi\circ (\pi_v\circ u)\\
&= \iota\circ\phi\circ v\\
&= w
\end{align*}$$
(because $\phi\circ v$ is equal to the co-restriction of $w\colon X\to H$ to $K$).
Thus, there exists a morphism $f\colon F\to H$ such that $f\circ u = w$. To prove uniqueness, we note that if $g\colon F\to H$ also satisfies $g\circ u=w$, then for every $x\in X$ we have $g(u(x)) = w(x) = f(u(x))$, so $g$ and $f$ agree on $u(X)$. Therefore, they agree on $\langle u(X)\rangle$; by construction, this equals $F$, so $f=g$.
Hence $(F,u)$ has the universal property of the free group on $X$, and hence is the free group on $X$ (up to unique isomorphism). $\Box$