Well it's not a universal rule to never scrap code. Sometimes the software is just so bad, so complicated, so wrong for the task that it must be scrapped. Large parts of Navigator, but also other things like OS 9 are examples. The original Mac OS was simply not cut out for an internet age -- like Windows 9x it couldn't be reworked to something current.
Even if Mozilla fails to keep their browser relevant, the investment is sure to pay off with a new widely respected system programming language. If you follow the reception of Rust virtually everybody seems impressed with the rationality and practicality of its design choices, explained and backed by solid engineering. Compared to the nearly universally panned golang (series of arbitrary decisions) or even Dart (decisions not backed by metrics), it's hard to imagine that Rust won't have a major impact on the industry -- that alone is worth scrapping the browser engine and rewriting from scratch.