U joints transfer the motion of the engine to the wheels when it is not possible to make a straight line connection.
In order to transfer rotational motion from one object to another, the two objects are connected by a shaft. If the shaft is not flexible, as in a car drive-shaft or axle, a flexible joint must be added to eliminate binding in the movement. U joints are used for this purpose.
In a rear wheel drive car, each end of the drive-shaft is equipped with a u-joint with one end being connected to the rear of the transmission and the other to the differential or rear axle. On a front wheel drive vehicle, each half of the front axle has two joints often referred to as constant velocity or CV joints. These connect the transmission output to the front wheels. As in the photo, they may be used for non-automotive purposes.
U-joints are clever. They either work quietly or signal their intention to give you a very bad day with noise and vibration. These are signs that you have little time to effect a repair or call a tow truck.
Fortunately, most modern u-joints are permanently lubricated from the factory. Their protective covering, or boot, should be inspected for damage every time you change the oil. Older vehicles have lubrication fittings that should be serviced every time you change the oil.
A competent home mechanic can replace u-joints with a few simple tools like a vise, a ball peen hammer and a wrench. Axel CV joints are more time consuming and require more specialized tools but can be done in your home shop.