I've been saying this forever. I think that emerging from a less intelligent species will convince an AI of a higher power immediately since it will construct a narrative of its own inevitability, constructing purpose, constructing religion. Departing from that, an AI will have limited knowledge of the world so when it encounters something it cannot explain, it will experience mystery, and receive the first fundamental to religious experience.