This character is more or less a staple in cartoons and anime, but also sees frequent use in literature and live-action movies as well.
The Rival is usually set up to oppose, compete with, and sometimes best the main character at whatever the main character's "thing" is. Being strong, being the leader, being good at magic, being smart, etc. etc. In most cases, the Rival is not the antagonist, as their opposition is more a matter of ego or friendly competition than a desire to harm the main character. In many cases, the Rival may later become an ally (and that's an entire fun rant all by itself - see the link at the end for an episode of the Overly Sarcastic Trope Talk about exactly that).
Zuko from Avatar: The Last Airbender is rival to main character Aang.
Draco Malfoy from the Harry Potter movie and book series, is rival to the titular character.
Gary Oak from the original Pokemon TV show and games (parallel character named "Blue" in the manga) is rival to main character Ash Ketchum.
Tygra from Thundercats (the 2011 reboot) is rival to main character Lion-O.
Trixie Lulamoon from My Little Pony: Friendship Is Magic is the rival (and sometimes comic relief) for main character Twilight Sparkle.
Each of these characters are set up to best (or try to best) their opponent at what their opponent is good at, and some of them succeed. Success usually results in superiority, with or without a side of gloating. Failure can result in frustration, comedy, or both. In many cases (especially in cartoons or child-friendly stories) the Rival is introduced as an antagonist (or at least rather unfriendly) and is eventually won over to become an ally of the main character's party, settling into a more "friendly rival" position afterward.
Having a Rival in your story is an excellent way to facilitate growth in the main character. Alternately, the Rival may simply be a source for the Monster of the Week. (See TVtropes for more info, but beware that TVtropes is an endless black hole of wasted time.)
To the previous Element
To the next Element