Now picture you're an aquatic animal, with a slow metabolism. You're a predator. The warmer you are, the better you can prey on other animals. So you drag yourself out of the water a bit, gills still working at the shore, and warm up a tad more than your neighbours. You're able to be a better predator, and are more likely to survive to propagate your genes. As time passes, more mutations lead to a better ability to get out of the water onto the land to bask. The Hox genes shift to make you a quadruped, and you can swim and maneouver on land--you're an amphibian.
I know that's highly simplified, but it's a good example.

