Note: The following is my opinion and is based primarily from the written Torah.
The Bible seems to take it for granted that animals naturally have some form of morality, wisdom/understanding, and holiness. In the story of Gan Eden the serpent is called the "most wise" of the animals, as if other animals are wise and the serpent simply happens to be the wisest. And when the snake sins, it is punished for its sin because it should have known better, just like Adam and Eve.
When we get to the flood story God beholds the whole earth and concludes that all flesh has become corrupt. Many commentaries limit this corruption to people, and limit it further to the corruption being the act of theft. This doesn't make sense on a peshat level because we know God is loathe to kill animals for no reason, for he says so very clearly in the book of Jonah.
Jonah 4:11
יא וַאֲנִי לֹא אָחוּס, עַל-נִינְוֵה הָעִיר הַגְּדוֹלָה--אֲשֶׁר יֶשׁ-בָּהּ הַרְבֵּה מִשְׁתֵּים-עֶשְׂרֵה רִבּוֹ אָדָם, אֲשֶׁר לֹא-יָדַע בֵּין-יְמִינוֹ לִשְׂמֹאלוֹ, וּבְהֵמָה, רַבָּה. {ש} 11 11 And should I not have concern for the great city of Nineveh, in which there are more than a hundred and twenty thousand people who cannot tell their right hand from their left—and also many animals?
It seems to me that God has concluded that nearly the entire animal kingdom has become corrupt just like mankind, and therefore he will destroy people and animals who are guilty of the same sin. It's beyond the scope of this answer to discuss what this joint sin might be, but feel free to ask that question as a separate post if you wish.
To further the point that the Bible views morality and wisdom/understanding as intrinsic to animals is the fact that God not only feels compelled to destroy animal life with man, God also establishes a covenant with animals and men as equal parties which is something most commentaries gloss over. We know they are being treated as equal parties because covenants are agreed upon with words and then a physical representation is made. Think the big rock for the covenant with Jacob and Lavan, the copies of the stones of the ten commandments. Usually each party gets either their own copy or has access to the physical representation of the covenant. Both Laban and Jacob can go back to the stone pillar, we hold both copies of the 10 commandments (one set for us the other for God) but we place them in the holy of holies where God resides. In the case of this covenant the rainbow is given which is in heaven, but also visible to man and animals.
Genesis 6:11-13, 17-22
יא וַתִּשָּׁחֵת הָאָרֶץ, לִפְנֵי הָאֱלֹהִים; וַתִּמָּלֵא הָאָרֶץ,
חָמָס. 11 And the earth was corrupt before God, and the earth was
filled with violence. יב וַיַּרְא אֱלֹהִים אֶת-הָאָרֶץ, וְהִנֵּה
נִשְׁחָתָה: כִּי-הִשְׁחִית כָּל-בָּשָׂר אֶת-דַּרְכּוֹ, עַל-הָאָרֶץ.
{ס} 12 And God saw the earth, and, behold, it was corrupt; for all
flesh had corrupted their way upon the earth. {S} יג וַיֹּאמֶר
אֱלֹהִים לְנֹחַ, קֵץ כָּל-בָּשָׂר בָּא לְפָנַי--כִּי-מָלְאָה הָאָרֶץ
חָמָס, מִפְּנֵיהֶם; וְהִנְנִי מַשְׁחִיתָם, אֶת-הָאָרֶץ. 13 And God
said unto Noah: 'The end of all flesh is come before Me; for the earth
is filled with violence through them; and, behold, I will destroy them
with the earth....... יז וַאֲנִי, הִנְנִי מֵבִיא אֶת-הַמַּבּוּל מַיִם
עַל-הָאָרֶץ, לְשַׁחֵת כָּל-בָּשָׂר אֲשֶׁר-בּוֹ רוּחַ חַיִּים, מִתַּחַת
הַשָּׁמָיִם: כֹּל אֲשֶׁר-בָּאָרֶץ, יִגְוָע. 17 And I, behold, I do
bring the flood of waters upon the earth, to destroy all flesh,
wherein is the breath of life, from under heaven; every thing that is
in the earth shall perish. יח וַהֲקִמֹתִי אֶת-בְּרִיתִי, אִתָּךְ;
וּבָאתָ, אֶל-הַתֵּבָה--אַתָּה, וּבָנֶיךָ וְאִשְׁתְּךָ וּנְשֵׁי-בָנֶיךָ
אִתָּךְ. 18 But I will establish My covenant with thee; and thou
shalt come into the ark, thou, and thy sons, and thy wife, and thy
sons' wives with thee. יט וּמִכָּל-הָחַי מִכָּל-בָּשָׂר שְׁנַיִם
מִכֹּל, תָּבִיא אֶל-הַתֵּבָה--לְהַחֲיֹת אִתָּךְ: זָכָר וּנְקֵבָה,
יִהְיוּ. 19 And of every living thing of all flesh, two of every sort
shalt thou bring into the ark, to keep them alive with thee; they
shall be male and female. כ מֵהָעוֹף לְמִינֵהוּ, וּמִן-הַבְּהֵמָה
לְמִינָהּ, מִכֹּל רֶמֶשׂ הָאֲדָמָה, לְמִינֵהוּ--שְׁנַיִם מִכֹּל
יָבֹאוּ אֵלֶיךָ, לְהַחֲיוֹת. 20 Of the fowl after their kind, and of
the cattle after their kind, of every creeping thing of the ground
after its kind, two of every sort shall come unto thee, to keep them
alive. כא וְאַתָּה קַח-לְךָ, מִכָּל-מַאֲכָל אֲשֶׁר יֵאָכֵל,
וְאָסַפְתָּ, אֵלֶיךָ; וְהָיָה לְךָ וְלָהֶם, לְאָכְלָה. 21 And take
thou unto thee of all food that is eaten, and gather it to thee; and
it shall be for food for thee, and for them.' כב וַיַּעַשׂ, נֹחַ:
כְּכֹל אֲשֶׁר צִוָּה אֹתוֹ, אֱלֹהִים--כֵּן עָשָׂה. 22 Thus did Noah;
according to all that God commanded him, so did he.
Genesis 9:9-10
ט וַאֲנִי, הִנְנִי מֵקִים אֶת-בְּרִיתִי אִתְּכֶם, וְאֶת-זַרְעֲכֶם,
אַחֲרֵיכֶם. 9 'As for Me, behold, I establish My covenant with you,
and with your seed after you; י וְאֵת כָּל-נֶפֶשׁ הַחַיָּה אֲשֶׁר
אִתְּכֶם, בָּעוֹף בַּבְּהֵמָה וּבְכָל-חַיַּת הָאָרֶץ אִתְּכֶם; מִכֹּל
יֹצְאֵי הַתֵּבָה, לְכֹל חַיַּת הָאָרֶץ. 10 and with every living
creature that is with you, the fowl, the cattle, and every beast of
the earth with you; of all that go out of the ark, even every beast of
the earth.
So just to recap, God seems to want to destroy all flesh because all flesh is corrupt. And for those that haven't become corrupted (both man and animal), God is going to save them AND establish a covenant with both man and animal kind. So without getting into the detail of just how much morality or wisdom the animal kingdom has, the Bible takes for granted that both exist naturally in animals to such an extent that animals can be judged as sinners worthy of the death penalty, or redeemed and have covenants established with them.