In verse 10 (Kings I, chapter 19), Elijah speaks badly of B'nei Yisrael. G-d shows him a phenomenon intended to change his position but Elijah then repeats the same thing in verse 14.
Seeing that Elijah did not get the message and has not changed his position, he gets replaced as the main prophet.
According to Rashi (on verse 16), Elijah's position was only that of prosecutor. Whereas Moshe had defended the people when G-d sought to destroy them. And that is why he needed to be replaced as the prophet (but G-d gave him the chance to change his position first with what happened in verses 11-13).
His claim of "I have remained alone" at this point seems a strange one. This is after the incident at Mount Carmel, and he had met Ovadiah along the way who had told him that he had saved certain prophets in the cave.
In addition, G-d can always make new prophets. The difficulty with Elijah is if he thinks he is the only one worthy, due to his zealousy, and that all the rest of Yisrael are too wicked.
Perhaps this incident is out of sequence, and happened before the incident at Mount Carmel. In some ways that makes more sense, but still it was necessary to replace him for the reasons Rashi outlined.