A peanut gallery is an audience that heckles the performer. The term originated in the days of vaudeville as a nickname for the cheapest (and ostensibly rowdiest) seats in the theater; the least expensive snack served at the theater would often be peanuts, which the patrons would sometimes throw at the performers on stage to show their disapproval. The phrases "no comments from the peanut gallery" or "quiet in the peanut gallery" are extensions of the name.
In the late 1940s the Howdy Doody show adopted the name to represent its audience of 40 children.
In recent times, the term has taken on new meanings with the advent of social networks and online chat rooms. "Peanut gallery" may also refer to a social network audience that passively observes a syndicated web feed or chat room.
The term itself is generally used on MW in the phrase: "don't take advice advice from the peanut gallery" for obvious reasons, which is to say, if someone is being negative, likely their advice isn't going to be that helpful.