Yes, foerigners can live in Bali permanently. There are a few visas and residencies available.
More info on permanent visa options for Indonesia