This question has been answered fairly well already, but one or two things are missing. First, the purpose of Hanon, or Czerny, or any of the other "finger exercise" books, is not to train you for when you run into figurations that are similar to the exercises. As the preface states: "In this volume will be found the exercises necessary for the acquirement of agility, independence, strength and perfect evenness in the fingers, as well as suppleness of the wrists..." Could you acquire these things through study of musical compositions? To a degree, yes, but Hanon (and other technique books) give your fingers a sustained level of work to do, with each exercise focussed on strengthening a particular potential weakness (trilling with the 4th and 5th fingers, for example). I can personally attest that playing daily through book one of Hanon, as a warm-up to working on other musical tasks, has given me a level of finger agility and strength I would not have achieved by simply jumping straight into the repertoire.
It is true that, to gain the benefits of this type of exercise, and not to succumb to any potential downsides, you need to be aware of what good hand position is and continuously asses the level of tension in your hands, wrists and forearms. Clench your fist. Feel what happens to your flexors in your forearm? You don't want that feeling when you're playing. Now open your hand flat and hold your fingers out straight, working to extend your fingers like you were about to palm a basketball. Feel the tension level in your extensors? You don't want that either. Your hand, at the keyboard, should look as it does resting at your side, without any tension. The fingers are naturally curved. If you play through the Hanon exercises slowly, with your hand in this position, your wrist neither too high, nor too low, and continually ask yourself "is there tension in my playing apparatus?" You'll be fine. One other thing, use your forearm to rotate your hand in the direction of the figurations, instead of locking your hand in place and using just your fingers. Rotation is one of the great (and lesser known) keys to good, supported technique. Go slowly. Don't expect to feel massive improvements overnight, but if you do this every day for 15 minutes at the beginning of your practice, you will see big improvements in your finger strength and independence. Then, next year, play them in all of the keys and you'll feel another jump. After that, learn your major scales, then your minor scales, then arpeggios. There's a never ending well of tools to build and extend your technique.
There's a reason why musicians work diligently and with specific exercises to develop their technique. It's the same reason why a sprinter hits the weight room and works to strengthen his entire body, instead of just running on the track every workout. Building strength, suppleness, and independence in your fingers is very important and Hanon is a legitimate tool for that purpose.