I don’t know what you mean by “inverted spine” — do you mean how fish swim side to side but dolphins swim top to bottom? That’s probably just chance, evolution has a lot of chance in it. Do you mean why are some invertebrates — don’t have any spine? I think those evolved first, and it is a pretty good solution putting your skeleton outside to protect you, but the problem is that it can’t get very large, because there’s not enough room inside anymore for the other organs, so skeletons are good for getting bigger.
One of the amazing things about life and the study of evolution is that sometimes there are big changes in an animal from one generation to the next with hardly any changes in the cells! This is called “epigenetic effects”, which means that it happens outside the gene, and we don’t understand it very well. But one of the main ways evolution is defined is by how many different animals have a particular gene. So the easy answer is that what has to change in the cells for evolution to happen is that there has to be a different number of some genes in a cell. This can happen just because some animals with some particular genes are more likely to live and have children. But once in a while it can happen because of a mutation. A mutuation is usually a mistake in copying the genes from one cell to another when the eggs or sperm were being made (or when a single-cell animal just split). Most of them are not very useful, but once in a while one is.
I was told once by a teacher of mine that the fact we have our backbone at the back was just chance…that evolution could have made it that animals had backbones along their tummies, and soft tummies on top! I think though, that if it really was better to have it the other way around natural selection would have evolved us to be like that.
For evolution to occur, two things are needed. First, there needs to be variation in a population (meaning there is some diversity, so we do not all have identical genes) and. Second, there needs to be new variation created (this happen by random mutations, which are copying errors that occasionally occur in DNA when it is copied). If there is variation in the genes in a population, it means that by chance, some will be a little bit better and some a little bit worse at surviving and reproducing in the environment. Over a long period of time, these small differences add up to make big changes. Mutation is important as it creates variation, and sometimes, by chance, a mutation will make an organism a little bit better at surviving, which means that organism will be able to have more babies that survive, and carry that mutation.