Gotham will have one more season 5. Season 5 will be it's last due to the low ratings according to Fox . I'm not sure why it has poor ratings because it's been a great series . Maybe another network or Netflix will pick it up .
Competition, plus subject matter that scews it to an older audience.
Plus the ratings threshold to keep a show on Fox are much higher than on CW (Gotham's ratings are about twice the superhero shows on CW). Not to mention it's expensive show due to production costs.
And since Fox doesn't produce it (it's done by Warner Bros), the threshold is lower than if it was a Fox produced show, as they won't get the income from syndication that more seasons would bring.
Warner Bros. could always move it to CW, like they did when CBS got rid of Supergirl.