Two uses in one: negate and reverse
With adjectives and past participles, un- reverses the meaning: happy → unhappy; known → unknown; expected → unexpected. With verbs, it signals undoing an action: lock → unlock; pack → unpack; do → undo. Before an adjective it means "not this way." Before a verb it means "reverse this action."