I think that one can roughly divide course material into four categories:
A) Cool and useful
B) Cool, but not clear if one will "need" it later
C) Painful to learn, but important later
D) Painful to learn and rarely if ever used, i.e. a waste of time.
This classification varies from one person to another. For example, for me differential forms are in class A and the Sylow theorems are in class D, but for someone more algebraically inclined the reverse might be true. (Incidentally I didn't learn differential forms in a course (although I could have) but rather studied them on my own, and in general these seem to be tragically underemphasized in some undergraduate curricula.)
In my own undergraduate education I think I had more of class B than anything else, but even if I didn't need the specific content later, I enjoyed myself and gained "mathematical maturity" and exposure to different kinds of mathematics.
I think that studying material in class C is not so good pedagogically. For me, if I try to learn something before I need it, then by the time I need it I have forgotten it all. In general, I think that courses sometimes have too much of a bottom-up approach, i.e. building up foundations before one knows what they are for. For example, going a bit beyond the undergraduate level, I have seen graduate students who are familiar with intricate technicalities in the foundations of algebraic geometry, but who struggle to come up with examples and don't know the most basic facts about algebraic curves.
In conclusion, I think that to the extent possiblein teaching and learning one should try to learn/teach things because they seem interesting, not because they might befocus so much on what is "needed" laterbut rather on what is "interesting".