I definitely approached choosing my university program based on what I felt would give me the most career options down the line. I work in the tech industry now, and I can definitely say the demand for folks in the sciences and maths won't be going away any time soon. However, I won't say that any job or career is completely resistant to layoffs or automation.
This video does a good job of explaining the value of university nowadays -- definitely not the same value as when Baby Boomers went attended university.
In my opinion, besides teaching you more about your program of choice, university teaches you how to learn and manage your time, as well as teaching you more about yourself. For example, after a while, I gave up on trying to have a certain term average/GPA because studying all the time was making me miserable. I started making more of a conscious effort to spend time with friends outside of class. Ironically, my average went up slowly over the course of my program even though I was "putting less time into studying." <: In reality, I was just being smarter with having more limited time to study and getting in time for rest and relaxation.