Encapsulation is part of abstraction. The concept of abstraction is the creation of an object to represent another object. As a rule, the original object is more complex than abstraction. Thus, abstraction is a representation, usually as an aid to memory, for terminology / communication, etc. Think of it this way: abstract art is something else. The steering wheel, gear and 2/3 pedals are an abstraction of how the car works.
Basically, an abstraction allows you to imagine something complex, with lots of details, as something much simpler. In my opinion, this is connected with a “piece” in cognitive science. We cannot keep complex things in our heads, so we simplify by abstraction, and then use abstraction. Design patterns are another great example. Instead of talking about the details, we can talk about the Command, State or Strategy template, etc.
Encapsulation is part of the formation / creation of abstraction. The smaller the interface of the object, the easier it is to abstract. You do not need to know how the engine and gearbox work in order to drive a car, you just need to understand their abstractions (gear change and accelerator). Engine parts and gearboxes are encapsulated (in the interface) to create an abstraction.
Encapsulation is necessary for abstraction because abstraction cannot cope with all the real details and complexity (otherwise it is not an abstraction). Thus, gear shifting is an incomplete representation (or model) of the gearbox, but it is complete enough for everyday use. Encapsulation can be thought of as "hiding details", which is necessary to create a simpler view.
It is also important to discuss the concept of “interface”. In most cases, the terms "interface" and "abstraction" in this case are less used interchangeably. An interface is part of a system with which a user interacts or interacts. The interface to the car is the steering wheel, shift gear and pedals, etc. Abstraction creates an interface. You are not dealing directly with the engine / gearbox; you are dealing with their respective interfaces.
Another reason for encapsulation is that we are dealing with an incomplete model / abstraction, we do not understand the full complexity of the original and cannot trust to deal with all variables (because we do not understand the complete model). This is important for decoupling because, without abstraction, the interacting components will know too much about each other. Think about it, because every car has a steering wheel, pedals and gear shifts, you can control any car, regardless of engine type, etc. In addition, the gearbox is abstracted from the engine. Otherwise, a special gearbox will be required for each custom engine.
Similarly, a class is an abstraction. A class represents some complex model, through its interface - public members of the class. This interface is created by encapsulation. The class is a simplified interface of its more complex implementation for its employees. You can also think of it as a “need to know." Class members do not need to know exactly how this works. Just as you do not need to know how the engine works to drive a car.
Encapsulation, interfaces, and abstraction play a crucial role in integration and communication, and therefore in the maintenance of your code. If you do not create good abstractions and do not violate the “need to know” principle, your code becomes confusing, fragile and a nightmare to change it, because there is no “buffering”. The concept of OO "say don't ask" is also related to this.