Lifelink causes you to gain life equal to the damage a source with lifelink deals. If your 4/4 lifelink creature attacks and deals 4 damage, you gain 4 life. It works for combat damage and any other damage that source deals—pinging with an ability, fight, even noncombat damage from an instant or sorcery that has lifelink (rare, but possible via granted abilities).
The big misconception: lifelink isn't a triggered ability, so it doesn't go on the stack and can't be responded to. The life gain happens simultaneously with the damage. This means if your lifelink blocker trades and dies, you still gain the life from the damage it dealt. Also, life gain from multiple lifelink sources isn't a single event—it matters for cards that count life-gain instances.
In Commander, lifelink shines for racing aggressive decks and combos with payoffs like Vito or Aetherflux Reservoir.