1. By asking them
There are multiple options for this, you can either use a feedback tool (often UX Tracking tools come with such a feature) or you can implement a "What is the reason you are leaving" question when people are aborting checkout for example.
Either way the majority of people will not answer you.
2. By watching what they do
If you are using a tracking tool like Hotjar, Luckyorange etc. you are able to see at what point a lot of users stop using your site and stuff like this, you have to look for patterns, for example people come to a product site and get confused because the information is to cluttered, they will move their mouse, scroll up and down and basically tell you that you need to try a different version of this site, which you can test and validate by comparing the dropout ratios etc.