When you do something for dear life, you do it as though not doing it would cause you to die. If a kayaker sees a shark in the water, she'll probably start paddling for dear life.
In some cases, people do things for dear life that really are death-defying: a window cleaner who slips off his scaffolding at the top of a skyscraper will hold onto it for dear life, knowing if he lets go, he'll probably die. On the other hand, a preschooler who doesn't want to share a toy might hang onto it for dear life when her friend demands a turn. The origin isn't clear, but it probably dates to the 18th century.