As you probably know, both of these comes from the transitive verb 위하다 (to do for the benefit of, do for the sake of). At least I think that verb is transitive, meaning that it requires an object. But that is not super important. :)
V기 위해(서) is used to indicate that the clause following this pattern is done for the sake of the preceding verb:
> "저는 한국에 가기 위해서 열심히 공부했어요." = "I studied hard in order to go to Korea."
Here, the preceding verb phrase is 한국에 가다 (to go to Korea).
The clause following our pattern V기 위해(서) is "열심히 공부했어요." ("Studied hard.")
Therefore we see that the translated meaning is "For the sake of going to Korea, I studied hard.".
위한 is a bit trickier. In Korean, as you might know, you can put verbs before a noun as to describe the noun like:
> 공부한 학생 = studying student, student who study (noun phrase)
> 음식을 만드는 사람 = food-making person, person who make food (noun phrase)
I'm not sure what to call these forms of verbs, but they are basically a way to attribute nouns as doing certain actions.
So 위한 is basically attributing a noun to be for the sake of something. Some examples, and please keep in mind that translations into English isn't super pretty since English doesn't really have an equivalent grammar form:
> 예술을 위한 예술 = a for-the-purpose-of-art art / art for art's sake (noun phrase)
The verb here is 예술을 위하다 (to do for the sake of art)
And the noun we attribute this verb onto is 예술 (art)
> 초보자를 위한 영어책 = a for-the-sake-of-a-beginner English book / English book for a beginner
The verb here is 초보자를 위하다 (to do for the sake of a beginner)
And the noun we attribute this verb onto is 영어책 (English book)
I think that is basically the difference between V기 위해(서) and 위한 and that they aren't really interchangeable. But I'm no Korean, so if anyone wishes to correct me, please do! :)