There is a long debate about the search engine ranking factors. Most important parts of SEO are on-page optimization ( content, headlines, meta tags, keyword density ) and off-page optimization ( link building, social media ). Most people tend to think that on-page optimization is responsible for a percent of the ranking, and off-page optimization for the other, but this is not true. Actually, they are 2 different things.
Let me put this differently. You can have the best optimized page in the world, but if you have no links then it is impossible to rank for a competitive keyword that is targeted by many websites ( you can rank for searches that match exactly your page title and there is no other page that have the same title ). For every keyword you want to target, google gives you a rank score, which is firstly based on the links pointing to your website. This score is amplified by the on-page factors like having keyword in title, having the keyword many times in a page etc. A page with 1000 links can rank higher than a page with 1500 links but where the targeted keyword is not in title.
Why I think that link building will be the most important factor for a good period of time ? When search engine started, they were not taking into account the links, and they relied only on the content. It worked at first, until webmasters figured out the algorithms and they wrote the content so they can rank better even if they valued less for searchers. Then search engines adapted and they started to consider that if someone link to a website means that the content of the website is relevant to the anchor text of the link and to the content of the linking page. Links are considered votes and it is not a bad thing to search for places where to put your link if they are legitimate, or to get a link building service.
It is true that people are making impressive efforts to cheat the search engines, buying links, getting into link-wheel schemes and many other tricks, but search engines are constantly improving the algorithm. There is a change that a website, even if bad tactics are used, to be able to rank on the first page, but they will get into a direct competition with other pages. If the content of the pages is not good and there is no value added for the searchers of that phrase, they will immediately hit the back button and google will notice this and can use this to improve the results. Also, good sites will get more links and will surpass bad websites.
Link building is not the only thing that matters, but it will still be important if it is done right.
Disclosure: Some of the links in this post are "affiliate links." This means if you click on the link and purchase the item, I will receive an affiliate commission