This is a very common question, and the answer really depends on the context, my answer for it is:
Q: I want to get a well paying, white collar job
A: You should be a specialist
Q: I want to do something like research, founding a company, etc
A: You should be a generalist
About the former context, the argument for being a specialist is that companies don't care about non-core skills, someone isn't more likely to get a job in consulting if he also knows chemistry, because it has no difference in performance(it might actually worsen performance, because of less time practicing core skills).
If companies had a choice in hiring either Linus Torvalds(Specialist) or Tom Scott(Generalist), they would choose Linus, because he probably would do the (coding) job better, meanwhile Tom hasn't coded in a while, and probably isn't in the know of the latest blazingly fast rust holistic microservices library.
Most of white collar jobs are de facto assembly lines, and it is trivial to know that generalists are useless for assembly lines.
But in the latter case is where generalists shine, since in this case the most important skill is to be right where everyone is wrong, which often requires being familiar with as much important facts as possible, but the importance of facts are measured in 1/niche-ness, so the more niche is a fact, the least important it usually is(there are exceptions, such when a previously thought niche fact turns out to be much more general), for example, knowing about Newton's laws of motion is much more important than knowing about moment of inertia.
This is why people who is successful in the latter case are so weird, they are so generalist that they can't fit into one single group, think of which group you could fully insert Feynman into? There's very little overlap between physicists and bongo players.