Normally, we want to know the truth and we want to avoid error. There is no reason why we can't achieve both. William James argues, however, that these are "two ways of looking at our duty in the matter of opinion"; not just two ways, but "ways entirely different". As he explains:
[T]hey are not two ways of stating an identical commandment, they are two separable laws. Although it may indeed happen that when we believe the truth A, we escape as an incidental consequence from believing the falsehood B, it hardly ever happens that by merely disbelieving B we necessarily believe A. We may in escaping B fall into believing other falsehoods, C or D, just as bad as B; or we may escape B by not believing anything at all, not even A. (James, 'The Will to Believe')
Avoiding error indeed does not guarantee knowing the truth, but the relation between these "two separable laws" is much closer than suggested by James's explanation. In most cases when a person acquires the true belief that p, she thereby avoids the error of believing that ~p. The avoidance of error in these cases is not just "an incidental consequence", for it has to do with the logical relation between p and ~p. Certainly we all have inconsistent beliefs, but if a person is aware of believing that p, she cannot at the same time believe that ~p (unless the belief is unconscious). This is especially so when the belief acquired is a result of rational inquiry.
James's target here is William K. Clifford, who advocates the principle that "it is wrong always, everywhere, and for anyone, to believe anything upon insufficient evidence" (Clifford, 'The Ethics of Belief'). Call this Clifford's Principle. As James understands it, Clifford's Principle "treat[s] the avoidance of error as more imperative [than the chase for truth], and let[s] truth take its chance"; for James, Clifford's Principle is in effect "Better go without belief forever than believe a lie". If this was how Clifford's Principle should be understood, then we could follow the principle simply by refraining, insofar as we can do so, from acquiring new beliefs. No new beliefs, no new false beliefs.
But this understanding can't be correct, for Clifford's Principle is a principle of rational inquiry. Rational inquiry is a pursuit of truth (some would argue it is a pursuit of knowledge, but knowledge entails truth), and a principle that can be followed simply by not acquiring new beliefs is not a principle of rational inquiry. No new beliefs, no new true beliefs either.
If we follow Clifford's Principle, we won't have unjustified beliefs. Since unjustified beliefs are more likely to be false than true, we can avoid error by following Clifford's Principle. But avoiding error this way is for the sake of knowing the truth; it is a means rather than an end. What Clifford's Principle explicitly tells us is that it is wrong to have unjustified beliefs, but the implicit message is that we should have justified beliefs. And the purpose of having justified beliefs is not avoiding error, but knowing the truth.
James finds it "impossible to go with Clifford" and is "ready to be duped many times [...] rather than postpone indefinitely the chance of guessing true". He believes that "worse things than being duped may happen to a man in this world". He is right, and one of those things is being duped and thinking it is a way of knowing the truth.