Somehow, nobody realized it – that part of William James Moriarty's plan all along was to die. Maybe Albert did; after all, he and William seemed to be much closer, or at least more closely linked in the entire Lord of Crime enterprise. That's largely out of their concern (or more precisely Will's concern) for Louis; it doesn't matter, after all, how old you and your younger siblings get, they'll always be your little brother or sister. In fact, there's a case to be made that Will's entire motivation in dying at the culmination of his scheme is so that Louis can live on, untainted by the acts his older brother committed – in the public eye, at least.
We have arrived, then, at the final problem. Canonically, this is the story that originally introduced Moriarty, both as the Lord of Crime and in general, so it may not be overstating to say that this is the point the entire series has been leading up to. William has groomed Sherlock Holmes for this moment, when he reveals himself as the mastermind behind all of the killings that have gone on throughout the storyline, although whether he envisioned Holmes actually killing him is up for debate, based on his reaction to Sherlock pulling the trigger on Milverton last week. That may truly be the moment when things went off the rails for Will; Albert mentions that the plan isn't the one originally laid out, and Will was shocked that Sherlock was willing to kill, as well as certain that the next man Sherlock Holmes would gun down would be William himself.
To a degree, that speaks of how Will underestimated Sherlock. He perhaps credited him with being more moral than he truly is, but he also failed to grasp that the other man truly likes him as a friend. It makes sense if you think about it: William is one of the few people, if not the only person, who can truly match wits with Sherlock, and he has the added benefit of not being Sherlock's overbearing older brother. Will may have had Sherlock dancing to his tune, but maybe that was part of the fun for the other man, a novel experience that had its own appeal; his failure to understand this could be read as the actual cause of William's change of plans, because his assumption is that Sherlock must be furious with him for all that he's done.
In fact, it almost feels as if Will is the more moral of the two men. He can jettison those morals if he feels he needs to, but when he talks to Fred after committing yet another murder, he sounds genuinely sad, like he knows he's sold his soul to the devil, or at least believes that he has. He's done so much to keep up appearances, and now he feels like he's been swept away in a raging current, headed for the falls ahead. Although he himself doesn't use those terms, it's still the impression we're given, and that's a neat bit of storytelling since we know the location where everything will come to its end.
Or where we assume that things will end, at any rate. Sherlock's anger at William is similar to what John says to him when he comes to the jail: he's furious that someone would do something like this for his supposed benefit without asking. Just like John didn't want Sherlock to save Mary at the expense of his morals, Sherlock doesn't want William to lionize him at the expense of his life – and if he doesn't want that, you can bet that Louis is even less keen on the idea. That Fred is the first to actively move to save William is a little surprising, but Louis really isn't far behind him. In fact, the two of them and Sherlock may actually have made up their minds all at once, and now they're all planning to offer William an escape from what he sees as inevitable.
William, of course, may not allow it. He's gone full Lady Macbeth in this episode, and it's clear that he believes that all the perfumes of Arabia will not sweeten his hands, for the damnèd spot will never come out. Given his actions in this episode, it's a little hard to conceive him as being worthy of saving, too. No matter if he did terrible things for the right reasons, he's still become a murderer many times over. Does he merit what will essentially amount to a third chance at life? It's hard to say, given what his death might do to others.
And while we ponder this, in the background, the sound of the waterfall is getting louder.