Apep attacked El-Ra, but was defeated by Set servant of El-Ra. In time Horus/Osiris/Serapis took over the role of Ra, and Set came to be unfairly associated with the Apep.
When the Horites had become powerful the Horus Kings began eating their firstborn sons as it was foretold that a firstborn son of Horus would be responsible for ending the Horite kingdom.