An analogous question regarding free groups can be found here.
INTUITION: A free $R$-algebra on indeterminates $X_1,\ldots,X_n$ is the noncommutative analogue of the polynomial ring $R[X_1,\ldots,X_n]$, which is a free commutative $R$-algebra on $X_1,\ldots,X_n$.
DEFINITIONS: For a commutative ring $R$ with $1_R$ and any set $X\!=\!\{X_i;\:i\!\in\!I\}$, the free (associative) unital $R$-algebra on $X$, denoted $R\langle X\rangle\!=\!R\langle X\,|\,\emptyset\rangle$, is the free $R$-module with basis the free monoid on $X$ of all (noncommutative) words (possibly empty) over $X$. Thus every element of $R\langle X\rangle$ has the form $\sum r_iX_{j_1}\ldots X_{j_i}$ and is called a noncommutative polynomial, where $r_i\!\in\!R$ (only finitely many non-zero) and $X_{j_1},\ldots,X_{j_i}\!\in\!X$ and $j_i\!\in\!\mathbb{N}_0$ (when $j_i\!=\!0$, the word $X_{j_1}\ldots X_{j_i}$ is empty, denoted with $1$); furthermore, $X$ is called the alphabet, $X_i$ are called indeterminates or variables or letters or generators, $X_{j_1}\ldots X_{j_i}$ are called monomials or words, and $r_i$ are coefficients. Multiplication is defined as follows: the product of two basis elements (monomials) is their concatenation, i.e. $(X_{i_1}\!\ldots X_{i_m}) \cdot (X_{j_1}\!\ldots X_{j_n}) := X_{i_1}\!\ldots X_{i_m}X_{j_1}\!\ldots X_{j_n};$ the product of any two elements (polynomials) just takes into account that $\cdot$ must be $R$-bilinear. For example, for $\alpha,\beta,\gamma,\delta\!\in\!R$ we have $(\alpha X_1X_2^2\!+\!\beta X_2X_3)\cdot(\gamma X_3\!+\!\delta X_2^3X_3X_1)$ $=$ $\alpha\gamma X_1X_2^2X_3+\alpha\delta X_1X_2^5X_3X_1+\beta\gamma X_2X_3^2+\beta\delta X_2X_3X_2^3X_3X_1$. When $|X|\!=\!n\!<\!\infty$, this algebra is denoted $R\langle X_1,\ldots,X_n\rangle$.
In short, for any set $X$, the free unital $R$-algebra on $X$ is $R\langle X\rangle:=\bigoplus_{w\in X^\ast}Rw$ with the $R$-bilinear multiplication that is concatenation on monomials/words, where $X^\ast$ is the free monoid on $X$ and $Rw\!=\!\{rw;\:r\!\in\!R\}$ is the formal free module on $w$, i.e. $rw\!=\!r'w\Leftrightarrow r\!=\!r'$. The empty word/monomial of $X^\ast$ is the identity $1$ of $R\langle X\rangle$. The map $i\!:X\!\rightarrow\!R\langle X\rangle$, $X_i\!\mapsto\!X_i$ is called the canonical injection. If we replace $X^\ast$ with $X^+$ (the free semigroup on $X$, i.e. $X^\ast$ without the empty word) in the above construction, we create the free nonunital $R$-algebra on $X$: $R\langle X\rangle^+\!=\!R\langle X\,|\,\emptyset\rangle^+$.
DEFINITIONS: For $S\!\subseteq\!R\langle X\rangle$, an algebra presentation, denoted $R\langle X|S\rangle$, is the $R$-algebra $R\langle X\rangle/\langle\!\langle S\rangle\!\rangle$, where $\langle\!\langle S\rangle\!\rangle$ denotes the algebra ideal, generated by $S$. The notation $\langle X\,|\,p_i\!=\!p'_i;\, i\!\in\!I\rangle$ simply means $\langle X|p_i-p'_i; i\!\in\!I\rangle$. Any $R\langle X|S\rangle$ is finitely generated / finitely related / a finite presentation if $X$ is finite / $S$ is finite / $X$ and $S$ are finite. An arbitrary (unital) $R$-algebra $A$ is finitely generated / finitely related / finitely presented if it has a presentation $R\langle X|S\rangle\!\cong\!A$ that is finitely generated / finitely related / finite. Elements of $S$ are relations or relators. These notions are analogously defined for the free nonunital $R$-algebra on $X$; the presentation is then denoted $R\langle X|S\rangle^+$.
COMMENT: Rings are $\mathbb{Z}$-algebras, so the above construction gives us the free ring on $X$, namely $\mathbb{Z}\langle X\rangle^+$, and free unital ring on $X$, namely $\mathbb{Z}\langle X\rangle$.
PROPOSITION (universal property): Let $i\!:X\!\rightarrow\!R\langle X\rangle$ be the canonical injection. For any unital $R$-algebra $A$ and any map $f\!:X\!\rightarrow\!A$, there exists a unique unital algebra homomorphism $\overline{f}\!:R\langle X\rangle\!\rightarrow\!A$ such that $f\!=\!\overline{f}\!\circ\!i$, namely $\overline{f}(\sum r_iX_{j_1}\ldots X_{j_i})=\sum r_if(X_{j_1})\cdot\ldots\cdot f(X_{j_i})$.
Proof: $\overline{f}$ must be a homomorphism and $f\!=\!\overline{f}\!\circ\!i$, so $\overline{f}(\sum r_iX_{j_1}\!\ldots\!X_{j_i}\!)\!=\!\sum r_if(X_{j_1}\!)\!\cdot\ldots\!\cdot\!f(X_{j_i}\!)$ must be satisfied, hence uniqueness of $\overline{f}$. It is also evident that such $\overline{f}$ is a unital algebra homomorphism. To prove it is well defined, assume $\sum r_iX_{j_1}\ldots X_{j_i}\!=\!0$. By definition, $R\langle X\rangle$ is a free module on $X^\ast$, thus $r_i\!=\!0$. Therefore $\overline{f}(0)\!=\!0$, and $\overline{f}$ is well defined. $\blacksquare$
COMMENT: by the universal property, $R\langle X\rangle$ is the free object on $X$ in the category of unital $R$-algebras.
PROPOSITION: Every unital $R$-algebra $A$ has a presentation, i.e. $\forall A\:\exists X,S\!:\: A\!\cong\!R\langle X|S\rangle$.
Proof: Let $A$ be generated by $X\!\subseteq\!A$ ($X:=A$ suffices) and let $f\!:X\!\hookrightarrow\!A$ be the inclusion. By the universal property, $\exists!$ algebra homomorphism $\overline{f}\!:R\langle X\rangle\!\rightarrow\!A$ that extends $f$. We have $X\!\subseteq\!\mathrm{Im}\,\overline{f}$, so $\overline{f}$ is surjective. Therefore $A\!\cong\!R\langle X\rangle/\mathrm{Ker}\,\overline{f}\!=\!R\langle X| \mathrm{Ker}\,\overline{f}\rangle$. $\blacksquare$
QUESTION: how can I prove the statement $R\langle X\rangle\!\cong\!R\langle Y\rangle\:\Rightarrow\:|X|\!=\!|Y|$ ?
I've thought of using the following theorem from Grillet's Abstract algebra (page 333): However, this just gives us $|X^\ast|\!=\!|Y^\ast|$. I've also thought of abelianising both algebras, so we get $R[X]\!\cong\!R[Y]$. But I'm not sure how to continue from here.