Can anyone explain the following theorem? When I try to understand it, it seems like a contradiction of a basis.
Is the vector v mentioned in the theorem not a linear combination of all the vectors in S, given the way v is derived? If it is a linear combination it can't be a basis, right? There is some part I don't understand correctly, I suppose.

What this theorem is saying, essentially, is that, given one basis of a finite-dimensional space, you can swap out one of the basis vectors for another, provided the new vector is a linear combination of the old set: the new set will still be a basis. You'll notice this is a Lemma, not a Theorem: I expect the authors are moving towards some theorems involving change-of-basis, which is quite important in linear algebra. This particular Lemma is not that important by itself except as a stepping-stone to change-of-basis.
Remember what a basis is: a set of linearly independent vectors such that any arbitrary vector is a linear combination of vectors in the set.