The name of the temple is named after the rock it was built on, with “Tanah” meaning “earth” and “Lot (lod/laut)” meaning “sea”. The temple is said to have been built in the 16th century by Dang Hyang Nirartha (a famous monk in Bali) to be built in the 16th century as a place to worship the Balinese sea gods.

The true origins of Pura Tanah Lot (the temple that sits atop Tanah Lot) are lost to the sea spray of time, but according to legend it was created in the 16th century at the behest of a now-mythologized holy man. Along with the other six sea temples along the Bali shore, each within eyeshot of the next, it is meant to pay respect to the guardian spirits of the sea. The constant pounding of the currents against the base of Tanah Lot have created a number of sea caves at the foot of the rock formation, many of which are home to sea snakes. These snakes are rumored to protect the temple from evil spirits along with a giant nightmare snake that lurks in the waters around the temple. 

At low tide, Tanah Lot can be approached on foot.  The outer sanctum of the temple is open to visitors (holy men receive and bless you), but the inner sanctum of the temple itself is forbidden to any non-Balinese visitors. The small caves exposed by the receding water can be explored, for those who are not concerned by snakes (real or otherwise).  There is a cave within a cave on the beach where visitors may approach and receive a blessing from the sacred snake.

The entrance fee to the temple for foreign visitors is Rp 60,000/adult and Rp30,000/child (from 6-12 years old).

According to Wikipedia and atlasobscura.com