Most bats are nocturnal.
They fly and forage for their food (bugs) at night. This means that
they need safe places to sleep during the day. Caves provide the
kind of protected shelter in which bats can thrive. Hanging from
the ceiling of a cave, bats are out of reach of most of their enemies.
Some of the most successful species of bats live in large cave colonies.
Some of these colonies have millions of members, even up to 20 million!
Carlsbad Caverns in New Mexico once had 7-8 million, but now has
about 1 million.
Source: http://www.loc.gov/rr/scitech/mysteries/bats.html