I'm not sure I understand the purpose of the different types of damage, i.e. if I take 3 cold damage as opposed to 3 fire damage, I lose 3 hit points, but what else? Is the only purpose that maybe I have defense against fire damage, but not cold damage?
Damage types have no rules of their own, but other rules, such as damage resistance, rely on the types. (Basic Rules, Chapter 9, p.75)
Damages type does not directly affect the damage you take. 3 cold damage and 3 fire damage are both 3 points of damage. Damage types, by themselves, do not have any additional game effect.
Damages types most often come into play with resistance, vulnerability, and immunity, which do affect taken damage. For example, fire elementals are immune to fire, meaning that your fireball spell would be unable to hurt them.
Player characters can also use it to their advantage, for example if you know you are going to face monsters that deal ice damage, most casters can cast the Protection from Energy spell beforehand, to gain resistance against ice damages.
In practice, as Strill noted in another answer, some resistance / vulnerabilities are more common than others. For example many undead are vulnerable to radiant damage, and very few monsters has resistance to it. Dealing fire damage can be quite frustrating at higher levels, followed closely by cold damage.
Please also note that DM can improvises damage type effects, for example a red dragon's breath (fire damage) may be able to start a fire... or may be not, such as when the dragon spread its breath too thin or too short. Similiarly, a white dragon may be able to freeze a pool - with the adventurers trapped in it. But these are ad hoc improvisations, not rules.
Damage types serve four purposes
- To identify what resistances reduce damage from that attack form
- To identify which vulnerabilities increase damage from that attack form
- To inspire creative narration of damage effects when appropriate and desired.
- To clue in certain folks about what kind of weapon is being used.
Two of these (#1 and #2) are specified in the rules (on PHB 197, and PBR 75), while the other two are based upon common sense.
The fourth use needs some unpacking. Not everyone knows what every weapon name means, and not every player is going to bother looking it up. The damage type implies something about the nature of the weapon and how it is used. When coupled with the other properties notes, it can provide a lot.
Further, the damage type implies what kinds of things it can be used for outside of combat.
EG: A maul is 2d6 bludgeoning, two handed, and heavy. The clueless should be able to figure out that its a blunt weapon and probably swung, and that it's BIG... and in truth, it is a large, long-handled hammer.
EG: A rapier is 1d8 piercing, finesse. Many are aware it is a type of sword. But not all folks know it's a thrusting weapon. And it's a piercing weapon because it's a thrusting weapon. This also implies (quite rightly) that it's not a great rope cutting weapon nor door chopping weapon.
EG: A character is in need of a hammer - any bludgeoning weapon should be able to be used as an emergency hammer.