The guardian is a front-line and defensively-minded soldier. Where the warrior is intent on cutting down enemies as quickly as possible, a guardian wants to dispatch his foes, but also wants to fight as long as possible, so as to allow his teammates more time to help him take down that fearsome foe that you're fighting against. Although GW2 eschews the "holy trinity" aspect of other MMOs, the guardian is still a good class to choose if you like to be up close and personal in combat while still soaking up damage so that weaker members of your party can thrive without worrying about, you know, dying all the time.
A guardian can shift into support and healing mode by picking up a staff.
When not hacking and slashing at opponents, guardians rely on their magic to help aid their companions with boons. They have a large number of utility skills that offer protection to other nearby players, such as by deflecting projectiles, creating barriers that enemies can't cast, offering them boons, and removing conditions from them. This emphasis on support makes the guardian a great class to play if you like to be a helpful teammate, but the guardian also gets some powerful offensive spells, such as their ability to call down spirit weapons which will fight autonomously on your behalf.
The guardian relies on three "virtues" in battle: the Virtue of Courage, which will allow the guardian to periodically gain a guaranteed chance to block an attack (called aegis); the Virtue of Resolve, which gives a bonus to health regeneration; and the Virtue of Justice, which will cause every fifth attack or so to cause the enemy to catch on fire. Each of these has a passive effect, so you can simply let them sit there if you like, but they all also have triggerable alternate modes, as well. Courage can be activated to give aegis to all nearby allies; Resolve will give a burst of healing to everyone in the area; and Justice will cause all nearby players' next attacks to cause burning, as well. Activating these effects will put your virtues on cooldown, though, causing you to lose the passive effect of them until the cooldown wears off. Still, it's a nice balance between solo buffing and group utility.
The specific attribute of the guardian is Virtue Recharge Rate. If you can increase it via your traits, your virtues will recharge more quickly after you activate them.