According to Moses, the fifth plague of Egypt killed all livestock except that of Israel. If all were killed, then why did Moses warn the Pharaoh to bring his cattle to shelter before the hail? The text states that many animals were killed as they did not bring them in. I don't understand this.
Your question really comes earlier, for in the plague immediately after the pestilence, we find:
which implies that the Egyptians had animals on which boils "broke forth".
Abarbanel, in his description of the pestilence (דבר), writes that part of the greatness of this plague was that the Jews in Egypt were able to profit from it. The Jews had an abundance of livestock (they lived in Goshen for this reason), and were able to sell animals to the Egyptians after the plague for exorbitant prices.
It seems, according to this theory, that the Egyptians did indeed have animals that were to be afflicted with boils in the subsequent plague and then killed if left outside during the plague of hail (barad).
Exodus 9:3 (emphasis mine):
This limits the scope of the plague to the animals in the field. Hence, any animal brought inside was not afflicted. So when Verse 9:6 says "all the livestock of the Egyptians died", it is referring to all the livestock that were in the scope of the plague, every one of the animals in the fields died. (Rashi to 9:10 based on the Mechilta).
Then the plague of boils, which was non-lethal, "attacked" every Egyptian person and animal, regardless of whether they were inside or not. (Exodus 9:10)
Then came the plague of hail, and Moshe warned the Egyptians that any animal or man left outside would get killed by the hail (Exodus 9:18-19), but any animal or man brought inside will be safe. Verse 20-21 tell us that the "G-d fearing" Egyptians brought their servants and animals inside, but the rest of the Egyptians did not. Verse 25 then tells us:
Once again only the animals in the field were struck, animals that were inside were unharmed by the plague.
Incidentally, this answers something else. In Exodus 14:6-7, it says that Pharaoh harnessed his chariot, and took 600 chariots with him. Where did those horses come from? Weren't all the animals killed in the plagues. The animals came from the "G-d fearing" Egyptians, who brought their animals inside for the plagues. (Rashi 14:7) (Which is why I put "G-d fearing" in quotations. They may have been scared of G-d's plagues, but as soon as they saw that their free labor had left, they gladly offered their horses to try and get the Jews back).