The PhD is has become the de facto replacement for the advanced workforce training programs (apprenticeship, guilds, corporate talent development programs) that many civilizations used to use. For some fields, you really do need to bang your head against a small number of problems without anyone holding your hand before you become proficient.
Not all PhD graduates get there; many just skate by because no one wants to fail them. They are an essential part of the modern labor force, though.