The guardian is a character who protects something. They can protect the protagonist and make sure that they complete their journey to defeat the antagonist. They can protect a specific building, or series of buildings, or an entire nation. In a story their purpose is usually to help the protagonist even if indirectly.
A good guardian character needs a reason to protect whatever they are protecting. No one does anything for no reason. Most of the time guardians are unhappy because they have sacrificed so much time and effort to protect what they need to protect, such as if a character pairs his friend up with his crush, or if they need to sacrifice their own lives to save the world.
Another thing to remember is that a guardian character needs something to protect. If they have nothing then they can’t be a guardian character (duh). If the guardian’s purpose is to defend the protagonist and they teach the protagonist everything they know then the character is more of a mentor type character.