Why does knuth mastermind algorithm favour guesses in S? From wikipedia : Mastermind > algorithms:

From the set of guesses with the maximum score select one as the next guess, choosing a member of S whenever possible. 

I understand that the hidden code is in S, so it makes sense to choose a guess in S over one that couldn't possibly win in the next turn. But, is this the ONLY reason that this step is necessary? or does it have a more important purpose?

As the Wikipedia article goes on to say

Knuth also gives an example showing that in some cases no member of $S$ will be among the highest scoring guesses and thus the guess cannot win on the next turn, yet will be necessary to assure a win in five.

Other things being equal, a guess in $S$ is likely to be better than a guess outside $S$ with the same score measured against remaining possibilities; as you say, you could then win on the next turn.  But Knuth's original article said on page 3 about $1462$ that the score is more important than being in $S$, if your aim is to assure a win in five guess overall, and Knuth's aim was to show his algorithm never did worse than that.
That does not mean Knuth's algorithm was best in every sense, and he showed that it was not. There are other algorithms with a lower expected number of guesses than Knuth's, but a worst-case number of guesses of six.
