A set of three orthogonally aligned torque rods wired up so they can generate a magnetic dipole field of either sign (i.e. flip the North and South poles) can generate a magnetic field of arbitrary orientation (up to the maximum vector sum of the dipole moment of each rod individually).
This artificial field interacts with the Earth's magnetic field to produce a net external torque on the vehicle that will tend to line up the fields. Mathematically, the torque is provided in the direction of:
$\mathbf{\tau}=\mathbf{\mu}\times\mathbf{B}$, where $\tau$ is the torque on the satellite, $\mathbf{B}$ is the ambient magnetic field, and $\mu$ is the magnetic field of the satellite
This torque only has two degrees of freedom, i.e. instantaneously the torque rods will tend to align the vehicle and Earth fields, with no control of the rotation of the vehicle around its magnetic poles. (see below for proof)
However, remember that the magnetic field lines around the Earth are themselves a dipole field, which is a toroidal shape.
This means as the spacecraft orbits the Earth it encounters a diversity of Earth magnetic field orientations and in general the time-averaged effect of this field diversity enables full 3-axis control.
That said, the field is weak, so the actual torque produced by torque rods is very small. It's completely unsuitable for agile spacecraft (e.g. imagers), for which attitude control effectors like reaction wheels or control moment gyros are typically used. Torque rods are used to desaturate these effectors which accumulate momentum due to disturbance torques like atmospheric drag, and to de-spin satellites (e.g. due to tip-off rates at launch vehicle separation).
Proof of the ineffectiveness of torque rods in the absence of magnetic field diversity
Torque rods rely on the change in direction of the Earth's magnetic field, which is especially problematic in equatorial orbits because (to first order) the field has a constant inertial direction. Equating the control torque with the rigid-body rotational equations of motion:
$$
\mathbf{\mu}\times\mathbf{B}=\mathbf{\tau}=\mathbf{I\alpha+\omega}\times\mathbf{I\omega}
$$
where $\mathbf{I}$ is the moment of inertia tensor, $\mathbf{\omega}$ is the vector body rates, and $\mathbf{\alpha}$ is the vector of body accelerations (i.e. $\dot{\omega}$), all in an arbitrary inertial reference frame. Moment of inertia matrices are always real and symmetric and can thus be decomposed / rotated into a principle reference frame.
$$
\mathbf{\mu}\times\mathbf{B}=\mathbf{Q\Lambda Q}^{-1}\mathbf{\alpha}+\mathbf{\omega}\times\mathbf{Q\Lambda Q}^{-1}\mathbf{\omega}
$$ $$
\mathbf{RQ\Lambda}^{-1}\mathbf{Q}^{-1}(\mathbf{\mu}\times\mathbf{B})=\mathbf{R\alpha}+\mathbf{RQ}(\mathbf{\Lambda}^{-1}\mathbf{Q}^{-1}\mathbf{\omega}\times\mathbf{Q}^{-1}\mathbf{\omega})
$$ $$
\mathbf{R\mu'}\times\mathbf{RB'}=\mathbf{R\alpha}
$$ $$
\mathbf{\mu''}\times[0, 0, Bz]=\mathbf{\alpha'}
$$
where $\mathbf{\mu}$ and $\mathbf{B}$ are rotated into the principle axes and the matrix math has shown there is no gyroscopic coupling between the axes of rotation in the principle frame because the $ \mathbf{\omega}\times\mathbf{I\omega}$ term cancels. (We could have started at this step by choosing the principle reference frame to start, but many seem comforted by starting with the full EOM.) We've additionally rotated by $\mathbf{R}$, selected so that the Earth's magnetic field only acts in the z-axis.
The vector $\mathbf{\mu}$ is our torque rod control input, which we may point in any direction by combining the effect of three orthogonal rods. This means the double rotation of $\mathbf{\mu}$ to $\mathbf{\mu''}$ has to be accounted for by the control system, but has no bearing on controllability. We can now expand the cross product and show despite the ability to point $\mathbf{\mu}$ in an arbitrary direction, the resultant acceleration (in the frame where the z-axis is aligned to magnetic North) has the form $[kx, kz, 0]$, which shows we can only control the angular accelerations about the x- and y-axes, but never z.
From the initial equation $\mathbf{\mu}\times\mathbf{B}$ we know a toque cannot be generated in the direction of $\mathbf{B}$; thus, any initial angular momentum in that direction is uncontrollable, but spacecraft kinematics can be counterintuitive, so sometimes the math is helpful.