If you find this topic interesting I'd highly suggest reading the book Other Minds [1] and maybe Being a Beast [2]. Apparently there was a Y fork millions of years ago in the tree of life where vertebrates and invertebrates split. It's interesting that both branches developed advanced nervous systems, specifically octopi and mammals. What's the purpose of an octopus having the highest brain to body mass of any invertebrate? Especially when they live ~2 years. Also, 2/3 of their neurons are found in its arms. Imagine thinking with your arms or seeing with your skin - they have photoreceptors in their skin and are able to match their environment yet they're color blind.
[1] https://www.goodreads.com/book/show/28116739-other-minds
[2] https://www.goodreads.com/book/show/28696605-being-a-beast