Batu Caves has been around for millions of years, but for most of that time, it was just part of the natural landscape. It was used occasionally by local Orang Asli communities for shelter and by Chinese settlers in the 1800s for collecting bat guano (fertilizer, basically).
That changed in 1878 when American naturalist William Hornaday wrote about the caves. His work caught the attention of British colonialists and local landowners. Still, at this point, there was no temple.