From the perspective of advancing science, journals seem mostly pointless and most of their benefit could be had at next to no cost if we just agreed to publish on the arXiv and pair it with a review system.
From the perspective of advancing scientific careers, because of how founders and institutions treat arXiv papers, you have to still publish in a journal, and so people keep publishing in journals.
But like, at least in physics time passes at the speed of arXiv posts, and getting published usually happens after it's been cited many times already. And if people are already incorporating it into the web of knowledge/responding to it etc., then what did the journal do?