The universal property implies that the map must be a one-to-one set-theoretic map.
To see this, let $a,b\in S$ be such that $g(a)=g(b)$. Let $G$ be a nontrivial group (e.g., $G=C_2$, the cyclic group of order $2$) and let $g\in G$ be a nontrivial element. Let $f\colon S\to G$ be defined by
$$f(s) = \left\{\begin{array}{ll}
1 & \text{if }s\neq a,\\
g &\text{if }s=a.
\end{array}\right.$$
By the universal property, there exists a group homomorphism $\varphi\colon F\to G$ such that $f=\varphi\circ g$. In particular, $f(b) = \varphi(g(b)) = \varphi(g(a)) = f(a) = g$, hence $b=a$ (since the only element of $S$ that is mapped to $g$ by $f$ is $a$).
Therefore, $g$ is one-to-one.
Once you know it is one-to-one, you may replace $S$ with $g(S)$ and consider it to be the inclusion, since the universal property also gives:
Theorem. Let $S$ and $T$ be sets, and let $f\colon S\to T$ be a bijection. If $(g,F_S)$ and $(h,F_T)$ are free groups on $S$ and on $T$, then $f$ induces a unique isomorphism $\Phi\colon F_S\to F_T$ such that $\Phi\circ g = h$ and $\Phi(g(s)) = h(f(s))$ for all $s\in S$.
Proof. Use the universal property of $(g,F_S)$ with $h\circ f$ to obtain $\Phi$. Then use the universal property of $(h,F_T)$ with $g\circ f^{-1}$ to obtain a map $\Psi$. Finally, use the uniqueness clause of the definition to prove that $\Phi\circ\Psi$ and $\Psi\circ\Phi$ are the corresponding identity morphisms. $\Box$
So we can replace a free group on $S$ $(g,F_S)$ with the free group $(\iota,F_{g(S)})$ which is free on $g(S)$, and which is canonically isomorphic to $(g,F_S)$.