(This is basically exactly what Brian mentioned in his comment, but in way more than 600 characters.)
Note that if $\mathsf{ZFC}$ refutes the sentence $\varphi$, then there must be a finite fragment $\Phi$ of $\mathsf{ZFC}$ which refutes $\varphi$. So what we are aiming for is to show that (relative to the consistency of $\mathsf{ZFC}$) this cannot happen.
So we begin with a finite fragment $\Phi$ of $\mathsf{ZFC}$, and we have in mind a forcing notion that should produce generic extensions satisfying $\Phi + \varphi$. Unfortunately, even demonstrating that the desired forcing notion $\mathbb{P}$ is an element of an arbitrary set model $\mathsf{M}$ of $\Phi$ might require axioms not in $\Phi$. Furthermore, the demonstration that the generic extension satisfies $\Phi + \varphi$ might also require axioms of $\mathsf{ZFC}$ not in $\Phi$ (because we will have to construct the required names, which will in all likelihood require, for example, instances of Replacement not in $\Phi$).
We must then analyse exactly what we need so that the above process can be carried out, and get a suitable finite fragment $\mathsf{ZFC}^*$ of $\mathsf{ZFC}$ such that if you begin with a set model $M$ of $\mathsf{ZFC}^*$ the forcing notion $\mathbb{P}$ is an element of $\mathsf{M}$, and, moreover, constructing a generic extension $\mathsf{M}[X]$ results in a model of $\Phi + \varphi$. This then shows (relative to the consistency of $\mathsf{ZFC}$) that the finite fragment $\Phi$ cannot refute $\varphi$.
This analysis can be carried out for any finite fragment $\Phi$ of $\mathsf{ZFC}$, leading to an appropriate finite fragment $\mathsf{ZFC}^*$ so that the above works. In this manner we can demonstrate the relative consistency of $\varphi$ with $\mathsf{ZFC}$.
Note that there are many relative consistency results that begin not with finite fragments of $\mathsf{ZFC}$, but rather of stronger theories, such as $\mathsf{ZFC} + \exists \text{ inaccessibles}$. The above description, mutatis mutandis, will handle those cases as well.
(But in practice we don't tend to worry about the particulars, and think of forcing over models of $\mathsf{ZF(C)}$ -- or stronger theories. Even more, (and perhaps far more often than the formalist in me would like to admit) we generally think of forcing over the entire von Neumann universe $\mathsf{V}$.)