At a high level, LockerService uses various technologies and techniques that are intended to do the following:
Prevent:
Components from causing XSS and similar security issues
Components from reading other component’s rendered data without any restrictions
Components from calling undocumented/private APIs
Enable:
Cool new features like client-side API versioning similar to REST API versioning*
Faster security review
Better and more secure JS development practices
Running 3rd party JS frameworks like React, Angular and so on*
Easily adding or removing new security features and policies
Check the below link for more information