How do i know how to use the 为?
I am no grammar expert, but let me attempt an answer based on my level of attainment. I am sure others could do better.

This is one of the most commonly occurring and useful word in the Chinese language, just about behind 的 &amp; 了。 

The problem is, (just like 的 &amp; 了), it is a preposition, and when used in combination it becomes a verb, a conjunction, an interrogative, (a sentence of inquiry that asks for a reply)

So it is in an actual sentence that its usages become apparent.

As a preposition it is "for"; 他的牺牲是为了什么?, (his sacrifice is for what?)

As a conjunction it is "because of"; 他为爱国以牺牲了生命, (Because of his love for country he sacrificed his life)

As a verb -- 成为 -- "become"; 他的牺牲将会成为传说, (His sacrifice would become a legend)

As an interrogative -- 为什么, "why", 他为什么牺牲自己的生命?, (why did he sacrifice his own life?)