Wouldn't so much call it an accident...the first beings were single cell, simple, had very few "components." To deal with certain environmental stimuly, they formed mitochondrial, scilia, etc etc. Then it became beneficial for more than one cell to group together, thus multicellular beings. These would evolve into colonies that would work together to achieve an instinctual common goal. Later on instead of existing as groups of identical cells, it became more efficient for some cells in the group to perform one function, while others performed a different function as they shared their singular benefits with the group. Isn't too hard to imagine where it goes from there...the cells become more and more specialized and are able to support a larger number of cells within the organism. There form groups within the whole that function as organs...etc, etc, etc. 600 million years later, here we are. 8)
How would they have an instinctual common goal? How can an organism go from no brainwave function at all, to having brainwave function? especially since when brain cells die, they do not regenrate. Once dead they are gone. So how does a non existent thing (brainfunction) come into being, when once it dies, it cannot regenerate?