4* is “world-leading", 3* is "internationally excellent but short of the highest standards”. How it's determined is by the panel that the papers are submitted to.
The official line is that the panel read each and every paper (even though to do this is not possible due to diversity of topics and time available). The reality is that it’s informed by metrics and is an appraisal of the title and abstract. A cynical person might give you a different answer about how it is done.