Free objects in a categories of groups, module and other algebraic structures, category-theoretic considerations Let $C$ be a category of groups or $R$-modules.
Usually, there is a "concrete" construction of a free group or a free $R$-module on a set $A$. For example, a free $R$-module on $A$ is usually any $R$-module with a basis $A$.
But if we use the categorical definition of a free object, we can define free $R$-module by universal property:

A free $R$-module on a set $A$ is any $R$-module $F^R(A)$ so that there is a set-function $j:A \to F^R(A)$ such that the pair $(F^R(A), j)$ satisfy the following universal property:
  $\forall R$-modules $M$ and $\forall$ set-functions $f:A \to M$ there is a unique homomorphism of $R$-modules $\phi: F^R(A) \to M$ so that $\phi \circ j = f$

The thing is, an $R$-module defined by universal property of a free object on a set $A$ in a category of $R$-modules doesn't even need to have $A$ as a basis.
Example: $R^{ \oplus A } = \bigoplus_{a \in A} R = \{ f: A \to R \ | \ f(a) = 0$ for all but finitely many $a \in A \}$
Define $j: A \to R^{ \oplus A }$ by setting $j(a)(a') = 1$ if $a' = a$ and $j(a)(a') = 0$ if $a' \neq a$. Also, then every function $f \in R^{ \oplus A }$ is a uniquely presented as $\sum\nolimits_{a \in A} r_a j(a), r_a = 0$ for all but finitely many $a \in A$ (actually, $r_a = f(a)$ ).
It's not hard to prove a lot of things about free modules with a basis $A$, say, $|A| = |B| \Rightarrow F^R(A) = F^R(B)$, where $F^R(A)$ denoted an $R$-module with a basis $A$.
But how many can we say about $j$ in case of an arbitrary $R$-module $M$ so that $(M, j)$ satisfy the universal propert for a free module on $A$? For example, can we say that (now by $F^R(A)$ we denote any $R$-modules satisfying the universal property)
$1) j$ is injective
$2) |A| = |B| \Leftarrow F^R(A) \cong F^R(B)$ ?
In general, are there any category-theoretic considerations which allows as to determine such things?
 A: The underlying category-theoretic notion is adjunction. You have a natural bijection of sets
$$\operatorname{Hom}_{R\textit{-Mod}} (R \left<X\right>, M) \cong \operatorname{Hom}_{\textit{Set}} (X, M).$$
This is precisely the universal property of free modules (a morphism $R \left<X\right> \to M$ is defined precisely by the images of the generators), and this means that the free module functor $X \rightsquigarrow R \left<X\right>$ is left adjoint to the forgetful functor $R\textit{-Mod} \to \textit{Set}$.
The universal property defines $R \left<X\right>$ uniquely up to isomorphism, and in general, if you have a (say, left) adjoint to some fixed functor, it is unique up to isomorphism. You should think of this as of the definition of free modules, and what you give is a particular construction, which is not that important, as normally we are interested in everything up to isomorphism.
The same definition works for free groups, monoids, algebras, Lie algebras, etc.: the construction of something free is left adjoint to the forgetful functor $\textit{Something} \to \textit{Set}$.
As for the properties you mention,


*

*The map $\eta_X\colon X\to R\left<X\right>$ (the inclusion of generators) is the adjunction unit. In general, $\eta_X$ is a monomorphism if and only if the left adjoint functor is faithful. In our case it means that the natural map
$$\operatorname{Hom}_{\textit{Set}} (X,Y) \to \operatorname{Hom}_{R\textit{-Mod}} (R \left<X\right>, R \left<Y\right>)$$
is injective: different maps between sets $X\to Y$ give rise to different morphisms between $R$-modules $R \left<X\right> \to R \left<Y\right>$.

*The property $|X| = |Y| \Rightarrow R \left<X\right> \cong R
   \left<Y\right>$ is just a consequence of functoriality: any functor
preserves isomorphisms.

*The other property $|X| = |Y| \Leftarrow R \left<X\right> \cong R
   \left<Y\right>$ you are asking for is simply false in general (functors always preserve isomorphisms, but they don't have to reflect isomorphisms: if $X\to Y$ induces an isomorphism $F (X) \xrightarrow{\cong} F (Y)$, in general this does not mean that $X\to Y$ is an isomorphism itself). $R^m \cong R^n$
does not imply $m = n$. When this is true, one says that $R$ has the
invariant basis number property.
