According to the BBC, antagonistic muscles are pairs of muscles that work by alternately contracting and relaxing. In the human leg, the quadriceps and hamstrings are one example of antagonistic muscles. As York College explains, skeletal muscles always work in groups and never work in isolation.
Muscles pull on the bones of the skeletal system to cause the body to move. HowStuffWorks.com explains that antagonistic muscle pairs work by pulling a bone in different directions to produce motion. For example, to pull the foot up towards the buttocks, the hamstring contracts, while the quadriceps relax. When it is time to straighten the leg, the quadriceps contract, while the hamstring relaxes, which straightens the leg.
The University of the Western Cape explains that muscles achieve movement by making bones move as levers. The quadriceps and hamstrings produce a third class lever, just as the biceps and triceps of the arm do; other parts of the body use first and second class levers. For example, the calf muscles, which allow humans to walk, produce a second class lever, where the load lies between the fulcrum and the effort applied. By contrast, the head and neck muscles create a first class lever when they cause the head to nod.