The correct answer is “for”.
The sentence “I shall not desert him for all the world” means that I will not abandon him no matter what happens. The word “for” is used to indicate the purpose or reason for something. In this case, the purpose is to not abandon the person.
The other options are not as appropriate in this context. The word “with” could be used to indicate that I am going to be with the person, but it does not convey the idea of not abandoning them. The word “from” could be used to indicate that I am going to protect the person from something, but it does not convey the idea of not abandoning them. The word “by” could be used to indicate that I am going to do something to the person, but it does not convey the idea of not abandoning them.
Therefore, the correct answer is “for”.