That show's ratings were down in its fourth year, but the news of its cancellation in March 2018 still came as somewhat of a surprise. The Librarians has a very dedicated fanbase that keeps the show trending on Twitter, and its ratings were still okay for a cable series. But the network was going through a period of rebranding, and apparently they decided the veteran show did not fit in as well with their new look (The Last Ship is also rumored to be on the chopping block after its upcoming fifth season). Producer Dean Devlin indicated that he will be shopping the show to other venues, and now is the time for fans to support it on the social networks.
Magic is not an exact science. If it were, it would be science.