You need to find a way to refocus your thinking so that the “worth” of a certain field or class isn’t only measured by how much you think you will use that knowledge in your future career. The point of college isn’t only (or even primarily) to prepare you for a job or a certain type of career. It’s about giving you a foundation from which you can learn a bunch of jobs and careers, and function in society as a citizen of a democracy. History is a great major for that - there is so much you can learn from the historical behavior and events of humans to help us understand modern problems and help us avoid making the mistakes of the past. There is so much about history that has shaped and influenced how humans behave today.
You are correct in surmising that life for academic researchers is difficult these days. Grant funding is often slashed in just the areas in which you’re interested, and history is a really tight field - there are far more job seekers than there are jobs as a professor in history. The vast majority of people who get a PhD in history won’t become history professors. But you don’t have to get a PhD in history just because you are majoring in history. You could do a lot of other things with the major. (And, even if you did decide that you really do want a PhD in history and want to at least try to become a professor - there are still lots of things you could do with a PhD in history outside of academia.)
Don’t chase a specific job/career just because you know it makes money. There are lots of things you can do that will earn you a decent standard of living without making you miserable. If you know you don’t like engineering, don’t do that. (I will say, though, that most engineers don’t do programming, and even engineers that do program don’t necessarily do that as the core part of their job.)
I think what you need to do is explore more kinds of careers that you can potentially do. For example, there are social science researchers (particularly in psychology, anthropology, sociology, and political science) in many corners of the economy, not just in academia. I’m a psychologist doing research in technology, for example, and some do research in education, at think tanks, at nonprofits, at financial firms and banks, at government agencies, and lots of other places. Look into those kinds of jobs. There’s also the prospect of compromising a bit and coming to a field that studies people but is a little more practical - like organizational behavior, marketing, behavioral economics, quantitative political science, etc.
Also, do note that every career field carries with it a bit of risk. People assume that computer science/tech will be rock-solid forever, but we thought the same things about law and real estate back in 2004, and that ended up not being true at all. There could be another tech bubble - many things could happen to the economy that change what the “hot” jobs are. That’s why you can’t rely on what makes a lot of money now alone to select your job.