Checksums are used to quickly validate that the received message has not been altered by spurious events in transmission.
They are added to the end of the transmission and checked by the recipient.
Any discrepancy results in the received packet being discarded. In UDP an external rectification process may be added by the application, it does not occur at the transport layer as with TCP.
Basically what it does is divide the bitstream by a large integer (32 bit), essentially a prime number.
The result is the remainder of the bitstream modulo the large integer. There is then essentially a 1 in 2³² (4 billion) chance of a spurious error creeping in undetected.
UDP is sometimes called ‘send and pray’, and is useful in places where speed and real time issues prevail and where errors can be discarded e.g. real time industrial control — a missed packet may be discarded if the next one arrives. By that time the discarded one is meaningless.
Think of a rocket flying to the moon, data is transmitted every second, but the round trip transmission takes 5 seconds or more.