A creature with link gains life whenever it deals damage. In other words, whenever it deals damage, the creature's controller gains that much life. So if one were to deal 3 damage with a lifelink creature to a player, one would gain 3 life. If the damage is prevented, one does not gain life. This applies not just to combat damage, but to any kind of damage dealt. For instance, if one were to put Lifelink on Prodigal Pyromancer, one would gain 1 life whenever it dealt 1 damage. The more the damage, the more effective lifelink is. That also means that the bigger the creature, the more effective.
Lifelink also does not do anything if it doesn't deal damage, in the case of first strike. For example, if one were to have a Child of Night on the field, and subsequently attack with it, and ones opponent has a Tundra Wolves, the opponent can block with the Tundra Wolves. Since it has first strike, it deals damage first and kills Child of Night. Child of Night deals no damage and the aformentioned summoner gains no life.
The amount of life gain via Lifelink's effect is equal to the attacking creature's power, not the enemy creature's toughness. If one attacks with a 6/6 Lifelink, and one's enemy blocks with a 1/1, the attacker would still gain 6 life.