SEO works by helping search engines to understand the content on your website and its relevance. Search Engines like Google use complex algorithms to decide which website should rank higher on SERPs.
These algorithm evaluate many factors like quality of content, does the content fulfil user intent,keyword usage,backlinks,user experience,and more.