One of the earliest AI presentations was in the 1965 novel Dune. Where the backstory is about how AI took control of the world at one point. The cardinal law in Dune was “Thou shalt not make a machine in the likeness of a human mind.”
Another was the 1968 Star Trek episode "The Ultimate Computer" where the first AI computer became sentient and started making some really bad decisions.
Asimov and Heinlein were writing stories about AI a decade before Dune.
Asimov's 1956 story "The Last Question," the AI Multivac outlived mankind and then actually outlived the universe itself, to the very heat death of the universe. Then it was finally able to answer "last question."
The earliest story about an AI that was globally pervasive is "The Machine Stops," a science fiction short story written by E.M. Forster. It was first published in 1909.
In "The Machine Stops," Forster envisions a future where humanity lives underground, and all their needs are provided for by an all-encompassing machine. The machine controls every aspect of people's lives, from providing food and shelter to facilitating communication through a worldwide network. People rarely interact face-to-face and prefer to communicate through the machine, which delivers audio and visual messages.
The story revolves around Vashti, who is content with her isolated life within the machine-controlled environment, and her son Kuno, who starts questioning the machine's authority and the nature of their existence. Kuno desires to explore the surface and experiences human connection beyond the confines of the machine.
"The Machine Stops" is remarkably prescient, considering it was written in the early 20th century, as it anticipates the internet, virtual communication, and the potential consequences of over-reliance on technology. The global pervasiveness of the machine in the story reflects the idea of an all-knowing, all-controlling AI that shapes every aspect of human life.