Triplets are used whenever you want to divide any duration into 3 equal parts in a simple time signature, because in any simple time signature, the beats can only be divided into 2, 4,... equal subdivisions (power of 2, basically).
In a simple time signature, usually two quarter notes equal to one half note; and three triplet quarter notes equal to one half note (two normal quarter notes). Similarly, three triplet eighth notes would be equal to one quarter note (i.e. two normal eighth notes). Triplets are usually written with a number '3' above or below the notes. Sometimes, you will see a square bracket or a slur across the triplet, and sometimes only the number is seen. Rests and dotted notes can be used as needed in triplets. This is one of the common ways to write triplets:

Triplets can also be considered the building blocks of compound time signatures, because all beats in compound time signatures are divided into 3 equal subdivisions. E.g. in the common time signature (4/4), if all four beats are written as triplets, it will be equivalent to the compound key signature 12/8. Since all beats in compound time signature are triplets, they will not be labeled as triplets, and therefore, a beat in a compound time signature is a dotted quarter note, instead of a quarter note.
Optional:
There may be circumstances where we want to divide one beat (a dotted note) in a compound time signature into 2 equal subdivisions. To achieve that, a duplet is used. Two duplet eighth notes equal one dotted quarter note (i.e. 3 compound eighth notes). Theoretically, one beat can be divided into n equal subdivisions, by the use of tuplets (the general term for notes like duplets and triplets).