Since there are users of this forum who would like to see a more explicit presentation, may I introduce a very general treatment.
In a given arbitrary ring, instead of using the terminology ''two-sided ideals'' I will instead call these bilateral ideals; given subset $X \subseteq A$ of ring $A$ I will write $(X)_{\mathrm{b}}$ for the bilateral ideal generated by $X$. Given two sets $M \subseteq N$ we use the notation
$$\mathrm{i}_{N}^{M}: M \to N\\
\mathrm{i}_{N}^M(x)=x$$
to refer to the inclusion map between the two respective sets.
For $I \subseteq A$ a bilateral ideal of ring $A$, we will denote the canonical surjection onto the quotient through $I$ by
$$\sigma_I^A: A \to A/I$$
In the one indeterminate polynomial ring $A[X]$, for any polynomial $f$ let us agree to denote its coefficient of degree $n$ by $f_n$. With this convention in place for arbitrary subset $M \subseteq A$ let us define
$$M[X]=\{f \in A[X]|\ (\forall n)(n \in \mathbb{N} \Rightarrow f_n \in M)\}$$
the set of all polynomials whose coefficients lie in the subset $M$.
Given rings $A, B$ and morphism $\varphi: A \to B$, by the universality property of polynomial rings there will exist a unique morphism $\psi: A[X] \to B[X]$ such that the relations
$$\psi \circ \mathrm{i}_{A[X]}^A=\mathrm{i}_{B[X]}^B \circ \varphi\\
\psi(X)=X$$
are both satisfied; we call this unique morphism the extension of $\varphi$ to the respective one indeterminate polynomial rings and denote it by $\psi=\varphi[X]$.
The following results are immediate from the definitons:
Proposition 1. Let $A$ be an arbitrary ring and $I \subseteq A$ a bilateral ideal. Then in the one indeterminate polynomial ring we have $(I)_{\mathrm{b}}=I[X]$.
Proposition 2. Let $A, B$ be arbitrary rings and $\varphi: A \to B$. The extension of $\varphi$ to the one indeterminate polynomial rings has the properties:
- a) $\mathrm{Ker}(\varphi[X])=(\mathrm{Ker}\varphi)[X]$
- b) $\mathrm{Im}\varphi[X]=(\mathrm{Im}\varphi)[X]$
Let us remark that as a consequence of this proposition we gather that surjective morphisms have surjective extensions to the respective polynomial rings.
Let us also recall the following version of the
Theorem of induced quotient maps: Let $A, B$ be two arbitrary rings, $f: A \to B$ a ring morphism and $I \subseteq A, J \subseteq B$ two bilateral ideals such that $f(I) \subseteq J$. Then there will exist a unique ring morphism $g: A/I \to B/J$ satisfying
$$g \circ \sigma_I^A=\sigma_J^B \circ f$$
This unique morphism $g$ will be called the morphism induced by $f$ and has the following properties:
- $\mathrm{Ker}g=f^{-1}(J)/I$ so in particular $g$ is injective if and only if $f^{-1}(J)=I$
- $\mathrm{Im}g=(\mathrm{Im}f+J)/J$ so in particular $g$ is surjective if and only if $B=f(A)+J$.
Let us remark that we have the following immediate
Corollary: if in the above $f$ is surjective such that $f^{-1}(J)=I$ then the induced map $g$ is an isomorphism.
Having introduced this theoretical apparatus, let us apply it to the concrete problem posted above: consider first the canonical surjection $\sigma: \mathbb{Z} \to \mathbb{Z}_5$ , such that $\mathrm{Ker}\sigma=5\mathbb{Z}$, surjection which by the consequence of proposition 2 will have a surjective extension $\varphi:=\sigma[X]$ to the respective polynomial rings. Note that by claim a) of proposition 2 we can infer that
$$\mathrm{Ker}\varphi=(5\mathbb{Z})[X]=5\mathbb{Z}[X]$$
Agreeing to simplify notation by $\sigma(n)=\overline{n}$ for any integer $n$, we have that $\psi(X^3+X+1)=X^3+X+\overline{1}$, by which $\varphi((X^3+X+1)\mathbb{Z}[X])=(X^3+X+\overline{1})\mathbb{Z}_5 [X]$ and hence
$$\varphi^{-1}((X^3+X+\overline{1})\mathbb{Z}_5 [X])=(X^3+X+1)\mathbb{Z}[X]+\mathrm{Ker}\varphi=(X^3+X+1)+(5)=(X^3+X+1, 5)$$
where we have used another relation ubiquitous in algebra, namely
$$f^{-1}(f(X))=X \mathrm{Ker}f=\mathrm{Ker}f X$$
valid for any group morphism $f: G \to G'$ between (multiplicatively written) groups $G, G'$ and any subset $X \subseteq G$.
At this stage, we can apply the corollary to the theorem of induced quotient maps to the particular case $A=\mathbb{Z}[X], B=\mathbb{Z}_5 [X]$, surjective morphism $\varphi: A \to B$ and ideals
$$J=(X^3+X+\overline{1}),\ I=\varphi^{-1}(J)=(X^3+X+1, 5)$$
in order to infer the existence of an isomorphism
$$\psi: \mathbb{Z}[X]/(X^3+X+1, 5) \to \mathbb{Z}_5 [X]/(X^3+X+\overline{1})$$
If for arbitrary $n \in \mathbb{Z}$ we agree to write $\mathbb{Z}_n=\mathbb{Z}/n\mathbb{Z}$ and for any polynomial $f \in\mathbb{Z}[X]$ to denote its canonical image in $\mathbb{Z}_n [X]$ by $\overline{f}$ (image which is obtained by extending the canonical surjection $\mathbb{Z} \to \mathbb{Z}_n$ to the corresponding polynomial rings and applying this extension to $f$; this is typically referred to as reducing $f$ modulo $n$), the above reasoning serves to prove that more generally one has
$$\mathbb{Z}[X]/(f, n) \approx \mathbb{Z}_n [X]/(\overline{f})\ (\mathbf{Ann})$$
where by $\mathbf{Ann}$ we refer to the category of rings, in the sense that the above isomorphism occurs precisely in that category (simply put, the two quotients above are canonically isomorphic as rings).