Sounds like "The Machine Stops", not a book but a novelette, by E. M. Forster; also the subject of this old question and maybe this one. Here is the plot summary from the Wikipedia page:
The story describes a world in which most of the human population has lost the ability to live on the surface of the Earth. Each individual now lives in isolation below ground in a standard 'cell', with all bodily and spiritual needs met by the omnipotent, global Machine. Travel is permitted but unpopular and rarely necessary. Communication is made via a kind of instant messaging/video conferencing machine called the speaking apparatus, with which people conduct their only activity, the sharing of ideas and knowledge. The two main characters, Vashti and her son Kuno, live on opposite sides of the world. Vashti is content with her life, which, like most inhabitants of the world, she spends producing and endlessly discussing secondhand 'ideas'. Kuno, however, is a sensualist and a rebel. He persuades a reluctant Vashti to endure the journey (and the resultant unwelcome personal interaction) to his cell. There, he tells her of his disenchantment with the sanitised, mechanical world. He confides to her that he has visited the surface of the Earth without permission and that he saw other humans living outside the world of the Machine. However, the Machine recaptured him, and he has been threatened with 'Homelessness', that is, expulsion from the underground environment and presumed death. Vashti, however, dismisses her son's concerns as dangerous madness and returns to her part of the world.
As time passes, and Vashti continues the routine of her daily life, there are two important developments. First, the life support apparatus required to visit the outer world is abolished. Most welcome this development, as they are skeptical and fearful of first-hand experience and of those who desire it. Secondly, a kind of religion is re-established, in which the Machine is the object of worship. People forget that humans created the Machine, and treat it as a mystical entity whose needs supersede their own. Those who do not accept the deity of the Machine are viewed as 'unmechanical' and threatened with Homelessness. The Mending Apparatus – the system charged with repairing defects that appear in the Machine proper – has also failed by this time, but concerns about this are dismissed in the context of the supposed omnipotence of the Machine itself.