Google has many criteria that underlie how your website will rank on searches. One criterion that clearly shows Google that your website should rank highly is whether there are many other websites that link to it. It shows Google that its content is very relevant and seen as valuable by others.
The key to link building is LOTS and RELEVANT content. Is your website rich in information, other sites will want to link to it, in order to be able to provide their visitors with additional information.
But the link has to be relevant to count at Google.
A relevant link is one that makes sense in relation to what your website and the website linking to yours is about. There has to be a relevant context for the link to be ranked as important.
If you have a website that is about dog breeding, a link from a website that is about cars will be a waste and not valuable link. If, on the other hand, you get a link from a website that deals with dog psychology, this will be emphasized as relevant.