Suppose you want to price a derivative $X$ (e.g. a barrier option). You simulate $M$ sample paths and compute $M$ potential discounted payoffs, $f_X$. The standard Monte Carlo estimate for the price of $X$ is simply the (arithmetic) average, $$\text{Price}=\bar{f_X}=\frac{1}{M}\sum_{i=1}^Mf_X(i).$$
The idea of control variates is that you use your $M$ paths to price another derivative, $Y$, which is (very) similar to $X$. For example, if you price a barrier option, then you can use a vanilla option as control variate. Importantly, for this control variate (the derivative $Y$), you need to know a closed-form solution, call it $f_Y^*$.
Now, you have got $M$ sample payoffs for $X$ (denoted by $f_X$) and $M$ sample payoffs for $Y$ (denoted by $f_Y$) as well as the closed-form solution for $Y$ (denoted by $f_Y^*$). Based on your sample payoffs, let's calculate $$\hat\beta = \frac{\mathbb{C}\text{ov}(f_X,f_Y)}{\mathbb{V}\text{ar}[f_Y]}.$$ This looks like a regression coefficient (market beta) or a minimum variance hedge. The new control variate estimate for the price of your derivative is then $$\text{Price}=\bar{f_X}+\hat\beta(f_Y^*-\bar{f_Y}).$$ The term $f_Y^*-\bar{f_Y}$ is the bias of your random numbers. Scaling the bias correction by $\hat\beta$ ensures that the new variance is at smaller (or equal to) the sample variance of $f_X$. The idea is that $\hat\beta$ emerges as optimal (i.e. variance minimising) solution of the problem
$$\min_\beta\; \mathbb{V}\text{ar}[f_X+\beta(f_Y^*-f_Y)]=\mathbb{V}\text{ar}[f_X]+\beta^2\mathbb{V}\text{ar}[f_Y]-2\beta\mathbb{C}\text{ov}(f_X,f_Y).$$
Clearly, the more $f_X$ and $f_Y$ correlate, the better the method. Imagine you price a down-and-out put option. This payoff actually correlates negatively with a vanilla put payoff. Not including $\hat\beta$ could make your price estimate worse!
Check out Boyle, Broadie and Glasserman (1997) for more details. For example, you can use several instruments simultaneously as control variates and the optimal $\hat\beta$ coefficients will, of course, look similar to those from
a multi linear regression.