The bat's ability for echolocation is amazing (so are other the abilities of other animals). I was wondering how all of it came to be.
The main reason for bats to "develop" their echolocation system was the avalability of an almost empty niche: Hunting insects at night. Birds are not able to hunt without light and here is where the bats come in. They are able to hunt at night and also to live and orientate in environments where they are protected over the day: Caves. Bats at night are also protected from predatory birds.
There is are a few interesting sources if you want to dive deeper into the stuff:
Remember, evolution says things don't initially develop "for a reason" -- they develop at random, non-harmful mutations are kept in the gene pool, and eventually a selection event occurs (opportunity to exploit another food source or avoid a hazard) which selects for the mutation in some subset of the population. Over the kind of timescales evolution works on, that's enough to take something that is harmless, turn it into something that is just barely useful (though not necessarily for what it's now used for, eg feathers), and then continue to randomly vary it so it works better or differently or whatever.
Echolocation by itself isn't so remarkable -- we generally can tell about what size room we're in by listening to the echos around us. It's focused echolocation that was a breakthrough.
Late addition: In fact, it is possible for humans to learn to echolocate well enough to get an accurate picture of their surroundings. Some blind individuals have demonstrated this under MRI imaging of their brains. It's not common, but this may be because not enough respect has been given to the technique -- just as ASL was not respected until deaf linguists were able to explain why it was so much better than the alternatives.
So maybe what's special about bats is not the ability, but their reliance upon it.