We learn that the people were killed because of their aveiros. But animals don't have bechira so why did they deserve to be killed as well?
2 Answers
Rashi (to Bereishis 6:7 DH “mei’adam v’ad beheimah”) seems to be bothered by your question, and he answers (2nd answer) that since everything was created for the sake of mankind, what is the point of keeping the animals around, if there’s no man to benefit from them?
מאדם עד בהמה. [...] דָּבָר אַחֵר הַכֹּל נִבְרָא בִּשְׁבִיל אָדָם וְכֵיוָן שֶׁהוּא כָלֶה מַה צֹּרֶךְ בְּאֵלּוּ:
Another answer: Everything was created for the sake of man; since he is being destroyed, what need is there for these [animals]?
This verse on which Rashi comments appears before Noach is described as being righteous and worthy of being saved. Perhaps even after that point, only an amount of animals proportional to the human population is required.
Besides Rashi's comment on Bereishis 6:7 gives both reasons for destroying the animals.
- Mankind had not only corrupted himself, he had forced the same corruption and degeneracy upon the natural world. Thus, the animals as well deserved destruction because of what had been done to them.
Consider that the Torah commands that an animal with which a person has committed bestiality must be put to death. This was even more extreme. Also the medrash states that the Ark only allowed in animals that had never been corrupted.
- Even had Man not done so, the animals would no longer serve a purpose on the world and thus, were to be removed.
from man to cattle: They too corrupted their way (Gen. Rabbah 28:8). Another explanation: Everything was created for man’s sake, and since he will be annihilated, what need is there for these [the animals]? (Sanh. 108a).
Rav Hirsch points out that this shows the greatness of Man and the degeneracy that he had inflicted on the world. Not only had he brought himself down but he had inflicted the same immorality and destruction on the natural world. This meant that Hashem would not have been able to destroy mankind and then create (or raise up from one of the species of animals) a sentient being that had been given free will in order to take over Man's position. The entire world had to start from scratch.
Hashem, the same mercy, the same Hashem of Love, that had placed Man on earth, now proclaims the decision for his destruction. The degeneracy was so great, that the extermination itself was an act of mercy. Even in the moment of his destruction, the greatness of Man shows itself in the fact that his destruction dragged the destruction of the whole living world with it. Not the world itself, but פני האדמה, the surface which belongs to mankind as the ground for its mission. It is not just merely a physical bond that joins men to things. It consists also of a moral relationship. When mankind sinks, the world mourns and withers. This fact runs through all the books of the תנ"ך. Further, it does not say אמחה את האדם, absolutely, but witht he addition of מעל פני האדמה. It does not exclude the possibiity that even this destruction was a relative one, removal from the earth. Whether even then the Godly element in Man is not preserved for other spheres, other conditions, that we can only dare interrogatively to hint at. The actual words of the text, anyway imply only relative destruction.