Most temple in Bali is for ritual purposes only with full preparation (proper dress, an offering & other detail things for the Balinese). But you’re welcome to enter some public temples in Bali, with strict rules. For example, for those women who are in period/menstruating are not allowed to enter the temple area. And also for those who are grieving and just gave birth, are also not allowed to enter the temple as it’s a sacred and holy place.
Sarong (cloth) is a mandatory cloth for those who enter any temple, to cover our knees below. It shows our respect to enter a holy place.