The class itself is already an act of grouping: it bundles a set of attributes and operations that belong to one concept, and draws a boundary.
A package is UML's general-purpose grouping construct. It collects related classes, interfaces, and even other packages under one name, and that name becomes a namespace — two classes in different packages can share a simple name without colliding.
A subsystem is a package stereotype with teeth: besides grouping elements, it declares behavior — it offers interfaces to the rest of the system .
A component groups classes into a unit meant to be swapped as a whole: a compiled module, a service, a library. It contains and more by the ports and interfaces to connect to external world.