The Block 1 CSM was in such bad shape in 1967 that even if by some miracle we sidestepped the fire, it is very likely we still would have had a serious problem, probably even a Loss of Crew (LOC) event shortly thereafter. If that LOC event occurred in orbit finding the root cause would have been extremely difficult and it may have delayed the program even further, possibly missing the end-of-the-decade mandate.
Truth be told, as horrific as it sounds, if Gus, Ed, and Roger had to die, then they died at the right time in the right place. We can take solace in the fact that their sacrifice probably enabled the moon landing as we know it today.