Firstly, Google uses more than 200 factors to rank a website. And the ranking algorithm changes frequently. Nobody (even their employees) knows exactly how the it ranks a website precisely.
In simple ways, it will try to deliver a result with the best quality and trusted content to fulfil the search request from a user. Thus, a domain’s E-A-T (Expertise, Authority, Trustworthiness) will decide how well a site rank in the search result.
In short, a reliable SEO company will do all the works to improve the E-A-T of your website so that it can rank well in the search result. It often take countless hours & months to rank a new web site.