The real role they play is something very different to everything that comes before in education, and a bit closer to everything in the world that will ideally come after: immersion in your field of choice in an environment full of curious peers who are variously a few steps ahead of you, all the way up to world class experts in the field doing research.
Parts of your interactions there may include being actively taught relevant things, but the more important goal is to let you explore this environment and the material (yes, with a bit of structure) and in doing so figure out how to learn on your own.
You absolutely should be able to get a degree with top marks without attending a single lecture, seminar, lab, whatever, just by reading the material and interacting with those around you less formally, and never being actively 'taught' anything.
Many in fact do something approaching this, particularly in the later years of a degree.