You can use "what" at the beginning of a sentence for two purposes:
- to ask a question:
What is a better way to spend the day than at the beach? (= I don't want to spend my day atgo to the beach today. Is there a better way to spend my day?)
- to emphasize your idea and to indicate that the thing you are talking about is the best.
What better way to get inspired than by accompanying a good friend? (= There is no better way to get inspired than by accompanying a good friend)
In your sentence, when he says:
But the more I played with the idea, the more I thought, What better way to ward Juli off?
he conveys that "His idea is the best and there is no better way to ward Juli off than his idea".