After he was banished by them, he fled to the desert and his kingdom and the authority and majesty which he had formerly were taken, because he boasted and said, "Who is the god, who shall take you from my hands?" [Daniel 3:15] Later stooping piteously to the earth, and wailing in the mountains, he lived with the beasts, fearing his satraps, lest he be killed by them. And on account of this Scripture says, "He shall lie outside in the grass and in the dew of heaven and with the beasts and his portion shall be in the grass of the earth. His heart shall be changed from men and a heart of a beast shall be given to him." [Daniel 4:15-16] For no longer did the great king and ruler live as a man administering the kingdom, but being alone in the desert he ate grass and herbs until his heart was changed and became as a beast who lived in forests and caverns, until his hair grew as a lion's and his nails grew large as a bird's and seven seasons passed over him. [Daniel 4:32] For in this way God the Most High interpreted these things to be, just as Daniel says, "The judgment is of the Most High, which has come upon my lord the king." [Daniel 4:24]
Source: Commentary on Daniel 3.9.2-5