This is an oil derrick, per wikipedia:
Another kind of derrick is used around oil wells and other drilled holes. This is generally called an oil derrick and is a complex set of machines specifically designed for optimum efficiency, safety and low cost. This is used on some offshore oil and gas rigs.
The centerpiece is the archetypical derrick tower, used for lifting and positioning the drilling string and piping above the well bore, and containing the machinery for turning the drilling bit around in the hole. As the drill string goes deeper into the underlying soil or rock, new piping has to be added to the top of the drill to keep the connection between drill bit and turning machinery intact, to create a filler to keep the hole from caving in, and to create a conduit for the drilling mud. The drilling mud is used to cool the drilling bit and to blow rock debris clear from the drill bit and the bottom of the well. The piping joints sections—usually each about 10 meters (30 ft) long—have threaded ends, so they can be screwed together. The piping is hollow to allow for the mud to be pumped down into the drilling hole, where it flushes out at the drilling bit. The mud then proceeds upwards towards the surface on the outside of the piping, carrying the debris with it.
The derrick also controls the weight on the drilling bit, because the drill bit works at an optimum rate only when it is pushed with a precise degree of pressure relative to the rock beneath it. Too much weight can break the drilling bit, and not enough weight will prolong drilling time. At the start of drilling extra heavy piping collars are used to create enough weight to drill. Since the weight of the pipes above the drill bit will increase the pressure on it as it goes deeper, the derrick will apply less pressure as piping sections are added. It will eventually lift the nearly entire drill string-and-piping complex to prevent too much weight as the well goes deeper.
And this is how an oil derrick works, per youtube:
("Its really basic. It took my like 10 min to animate. dont judge it.")