Interesting that this involves a response similar to an immune response to a pathogen. I've read a couple articles about alternate theories of Alzheimer's linking it to an increased immune response in the brain.
Maybe that is the origin? Cells learning to counter different threats and communicating that information to other cells could be a plausible first step towards intelligence.