Why are journals used in modern scientific academic research?
Why are so many people publishing [on ArXiv]?


You have to be careful with terminology when making statements like that. ArXiv is certainly "publishing" in the literal sense of "making public" but would you say that you'd "published a book" if you'd just put it on your website? Probably not.


  My question is, why were journals used to begin with?


Because they predate ArXiv and the web by hundreds of years, though the format has changed over time.


  Why are they used now?


Partly through inertia, partly through a lack of alternatives. On a purely scientific level, ArXiv itself is not peer-reviewed. On a non-scientific level, ... People have an intuition about the quality they expect from a paper that appears in a particular journal and we don't have alternatives that allow us to make this kind of judgement. Correspondingly, certain journals have quite a lot of prestige, which is important for students early-career researchers who are looking for promotion; a large fraction of papers have at least one such author. It's easier for people like Tim Gowers to work outside that system.