All industries, at least in capitalist economies, sell something. The television industry may produce TV shows, but what they sell is you. Or, more accurately, they rent you in fifteen-/thirty-/sixty-second increments to people who want to tell you something, and most often want to sell you something.
The shows exist to create a product (the viewing audience) that the networks can sell. And, like producers of livestock and cheeses, they grade the product by types. These types are called "demographics", from the Greek words for "people" and "writing". The demographics one falls into are based on several factors, such as age, sex, race, income, and geography. Note that not all components are included in every description. As different kind of people buy different kinds of products (for example, you won't be finding people in the 2-11 demographic that are interested in buying cars), advertisers are only interested in the demographics that are likely to actually buy their products.
Shows are described to potential advertisers in terms of the demographics they appeal to, as in "This show has a strong following among eighteen- to twenty-four-year-old males."
Demographics are a component of the ratings system. It doesn't matter if a high number of people tune in every week if they aren't interested in what the advertisers have to sell. For subscription-based services like Netflix and paid channels like HBO and Showtime, though, this isn't an issue, since they don't rely on advertising to make their money.
Changing which demographics a show appeals to is often the cause of Executive Meddling. It is a reviled indicator of the increasingly mathematical and cold process by which television is produced.
Demographics started to be identified in the late 1960's, early 1970's. In a "What If?" scenario, some people believe that if this process was known earlier, Star Trek: The Original Series might have lasted longer. Despite the mediocre total number of viewers, Star Trek hit the golden demographic range of 18-45 male adults and the doctors/scientists/teachers intellectual market dead on. This knowledge that this series was nailing the exact audience advertisers drool for is what kept reruns going for several years. Conversely, the rise of demographics led to The Rural Purge, where several shows, despite their overall popularity, were cancelled due to their lack of popularity with young urban viewers.