Generally, a show's ratings are compared to the ratings of other shows on the same network. If a show's ratings are significantly lower than those of other shows, it is more likely to be cancelled. However, there are exceptions to this rule. For example, a show with a small but loyal audience may be renewed for another season even if its ratings are low.
The decision to cancel a show is ultimately made by the network executives. They consider a variety of factors, including ratings, production costs, and the availability of other programming.