Quite simply, any marketable item (including a company or share of stock in a company) is worth only what people are willing to pay for it.
That's why there is a stock market. Literally every trade made is because there is a seller with an "ask" price, i.e. "I want to sell my share of XYZ for $100", and someone is willing to buy that share for that amount. Likewise, someone can say, "I'd like to buy a share for $100" (that's called a "bid"), and a seller agrees to sell at that price. The stock market just helps connect those buyers and sellers.
Some stocks don't sell at the price asked, and the trade doesn't happen. Some stocks have low volume and hardly trade at all. Investors use all sorts of reasons and criteria for setting their prices. Often, those criteria include earnings and dividends, but sometimes those things don't factor much into the price.
Ultimately, the price of a stock is set by the the people buying and selling shares, not by the company itself.