The compositor is the program that stitches the framebuffers for each element on the screen together into the final image. It is usually a part of, or closely related to, the window manager.
Modern drawing APIs typically work by allowing the application to ask the windowing system for a buffer (may be hardware accelerated) to which the application will perform all of its draw calls. The compositor then gathers all of the frame buffers and uses attributes to draw the final image into its own frame buffer that is then sent to the graphics adapter's swap chain. The compositor handles things like window order, overlapping, decoration, translation (movement), projection, magnification, resizing, rotation, etc...
The advantage of using a compositor is that an application need not worry about competing with other applications for screen space. Each application renders to its own buffer while remaining blissfully unaware of the existence of other applications.