The tuning pegs on a guitar allow a guitarist to adjust the tension on their guitar strings. The tension on the strings determines what note is heard. If the string's tension is not high enough, then the note may seem flat.
A tuning peg works by threading a string through a cylinder. That cylinder lies in a type of gear. Thus, by turning the peg, the string can be tightened and loosened as needed.