If there were no tensioner and the rig moves downward, the riser would buckle; if the rig rises then high forces would be transmitted to the riser and it would stretch and be damaged.
Tensioners have historically been composed of hydraulic actuated cylinders with wire sheaves.
More recently, active electrical motors have been used for compensation purposes.
The cylinder is connected to a number of high-pressure gas bottles via a medium separator.
A wire rope is rigged in the cylinder; one end is connected to the fixed part of the tensioner, the other end is connected to the riser.