1.) To sit there and look powerful, and ideally dissuade potential adversaries from forcing you to build a wartime military.
2.) To experiment with a bunch of new technologies, so that when you need to go to war, there is some report buried on a bureaucrat's desk detailing precisely the capabilities that the wartime military will have.
3.) To keep military industrial capacity alive, so that you don't have to build new shipyards & tooling from scratch if war breaks up.
4.) To keep military human capital engaged & employed, so that you don't need to train up a generation of engineers to build the tooling to build the war machines that you actually want.
5.) As a form of Keynesian stimulus & political welfare, to redistribute money from wealthy regions of the country to poor regions.
In basically every military conflict since the American revolution, people have found that military doctrine is going to be out-of-date, and all the best tactics & weapon systems you thought you had are largely useless. When Vietnam started, we thought that the war would be conducted through missiles, airplanes, and ICBMS; instead we had a long hard slog of infantry jungle warfare. When Korea started, we thought the next war would be nuclear and over in an hour; instead, jets & amphibious landings had a large place. When WW2 started, we thought we'd have a titanic clash of battleships; instead, the whole naval war was fought by submarines in the Atlantic and aircraft carriers in the Pacific. There's no reason to believe that the next war will be any different; for all we know, it'll be fought with drones in the sky, or hackers in cyberspace, or maybe we'll finally get the nuclear apocalypse that we thought Korea would be.
The point of a peacetime military is to keep options open so that when you find out just how the next war will be fought, there is some low-level engineer, somewhere, who has been experimenting with precisely the technology you need, and can be rapidly promoted and tell everyone else how to do it. Things like the Gerald Ford or F-35 fit right into that strategy. They aren't intended to be fighting machines in their own right; they're floating/flying R&D platforms for developing new technologies, most of which are useless but a couple of which will probably be crucial.