The reason why the Flood exists is because the Forerunners have negative common sense.
The Forerunners are a typical sci-fi hyper-advanced ancient civilization.
One day a spaceship of unknown design crash lands on a Forerunner planet.
Inside the spaceship there is an unknown substance.
They decide to feed this unknown substance to their dogs.
It starts to mutate their dogs making them bigger, stronger, smarter, easier to train, etc. so they keep feeding it to their dogs.
Their dogs start growing hair on their backs, which is odd since they were completely hairless.
Then the dogs start eating the hair off of the other dogs, mutating the dogs who eat it as well.
Then the dogs stat eating each other, which is bad since they were herbivorous.
Then the dogs start growing like, spider legs and stuff, at which point they realized that maybe they should stop feeding the mystery substance to their dogs.
It's too late, however, because the dogs have turned into Flood.
After a very long time of trying to fight the Flood, they realize that wiping the galaxy clean is the only option.
They build the Halos to kill everything in the galaxy that has a central nervous system, since that's what Flood infects.
They keep a bunch of animals in shielded areas to repopulate the galaxy after the Flood starves to death.
They also saved some Flood too.
Not some Flood infected animals that slipped past, that'd at least make sense in a tragic way, but just some Flood.
So they wiped the galaxy clean of life to kill the Flood and then went out of their way to save it so that it could affect the things that survived it.