Google AdWords works on the basis of a bidding system, where the bid price and quality score determines if an ad will appear on the top of Google page. Higher the bid and quality score, better are the chances of an ad being on top.
When someone searches for anything it generates an Ad copy on search result page and clicking on it, generates cost. So it is called 'Cost per click'. Google matches the search query with the keywords present in the AdWords’ advertiser keyword pool. If a match is found, Google will run an algorithm aimed at determining relevance and quality, also known as the keyword quality score, alongside the bid placed by the advertiser.