Oftentimes humor in anime and manga can be traced to the Japanese tradition of Manzai. Most people probably read that line and are asking themselves, "Well, what does that mean?" Believe it or not, stand-up comedy is a long and storied tradition in Japanese culture, and that tradition has influenced just about every avenue of comedic entertainment in that country.
Even though the word itself only dates to about 1933, Manzai comedy is an institution that has its roots in the Heian period (794-1185.) The tradition has been the strongest in the Kansai region of Japan, and therefore comedians often speak with this area's dialect. This has lead some North American distributors of anime to have Kansai characters speak with southern US accents in the English dub to try and mimic this flavor!
Most Westerners are familiar with a 'funny man/straight man' comedy act where one character in a comedy team acts serious while the other acts out any variety of antics. In the same vein, Manzai has Boke and Tsukkomi characters. A Boke character is silly while a Tsukkomi character takes everything in a situation seriously and tries to correct the Boke's mistakes.
The next time you watch The Melancholy of Haruhi Suzumiya, for instance, pay attention to Kyon and the way he has to react to the insane ideas that Haruhi comes up for him to act on. He usually is forced to clean up after the eponymous character follows through on one of her absurd schemes. However, this sort of dynamic isn't restricted to off the wall comedies.
Take, for example, some of the relationships in the Bleach anime. Toshiro Hitsugaya often plays the straight man Tsukkomi role to the Boke antics of Rangiku Matsumoto. Rangiku has a tendency to cause a lot of problems for Captain Hitsugaya, and she usually ends up making him do more work than he would have otherwise had to. Hitsugaya also has a bad habit of getting mistaken as a child, much to his chagrin.
The effect of Manzai on Japanese entertainment could fill volumes, and the actual pure genre is still popular to this day. Therefore, countless anime series pay at least some sort of homage to the practice. In fact, it will sometimes have a direct reference. For instance, Keiichi Morisato in Ah, My Goddess mentions that his Manzai records probably wouldn't be construed as very romantic. Whether it has an overall serious or humorous, keep an eye out for references to this long and storied Japanese tradition.