for; in order to; for the benefit of
ために expresses purpose or benefit, meaning 'in order to' or 'for the sake of'.
ために has two main uses. When it follows a verb in the dictionary form, it means 'in order to' and expresses the purpose of an action. For example, you do X ために Y, meaning you do Y for the purpose of X. The verb before ために is something you want to achieve, and the verb after is what you do to achieve it.
When it follows a noun with の, it means 'for the benefit of' or 'for the sake of'. In this case, the noun is often a person or a group. You do something for their good. This use is common in both speech and writing, but the purpose use with verb is more neutral and common in everyday speech.
Note that for the purpose meaning, the verb before ために must be in the plain non-past form, not past or ます-stem. For the benefit meaning, you cannot use a verb directly with ために without の if it is a noun? Actually, you can also say 家族のために (for family) but not 家族ために. So always use の after nouns.