1. Reference to Roger:
Since Luffy inherited Roger’s Will, he and Roger are bound to have many similarities. So Luffy could get sick with the same or a similar illness like Roger had, before the Great War starts.
2. Chopper’s Dream:
Since Chopper’s Dream is to cure diseases that he encounters, he can of course heal it. But he needs some time, so the finished cure is ready after the Great War. He then tells Luffy to barely use his Gears because they shorten his lifespan and he doesn’t have much more left due to the illness.
3. Luffy’s Lifespan is already shortened from Ivankov’s Booster and Healing:
It’s all heading to the part where Luffy can’t fight anymore, will get sick and/or dies.
4. Ope Ope no Mi and the “Immortality Operation”:
I’d like to remind you of the concept of Chekhov’s Gun: “Chekhov’s gun is a dramatic principle that suggests that details within a story or play will contribute to the overall narrative.” This encourages writers to not make false promises in their narrative by including extemporaneous details that will not ultimately pay off by the last act, chapter, or conclusion.”
The Operation is then the only hope for Luffy in the Great War. It would also make a nice sacrifice and a great Plot twist. Additionally would Law pay off his debt to Luffy after he saved Law in Dressrosa where he should have died against Doflamingo. From that point on he was living on the life span that was given by Luffy, so he would have a reason to do it.
(It’s not a main argument for this theory but Luffy would have had a total of three lives in the whole series/manga. This leads to the “Rule of Three” Oda often used).
5. Chopper’s Dream becomes Reality:
After the Strawhats win the war, Chopper has enough time to make the cure, that not even Crocus could do for Roger. Then he becomes the best doctor and he could cure all diseases. He saves his Captain who is now the man with the most freedom of all.
TL;DR: Luffy gets sick before the Great War and dies in Battle because his lifespan is already short and his gears are further shortening it. Law then sacrifices himself for the Pirate King and does the “Immortality Operation”. Chopper can heal the disease after the War so he can acchieve his ultimate goal.
Theory by AlphaJoshi69420 (https://www.reddit.com/user/AlphaJoshi69420)