Okay here's an attempt from someone who hasn't taken finance 101: when you buy something, anything, you would do some research to make sure you are not overpaying for it, and ideally you would like to find a bargain, i.e., pay less for what you perceive as the value of the thing you are buying. For example, when shopping for a car, you first would look into the specs and features of a car: 4 door, 2 door, 4 cylinder 6 cylinder, 2 liter 5 liter, leather seats etc. Then you would consider other things like re-sale value: You know that certain brands tend to re-sell higher than others. Then finally you might even consider the potential costs to maintain and operate the car, i.e., how often do you need to service and fix it, and what is the gas mileage. Then you would shop around to get the best price on the car you want which depends on the specs and features, maintenance cost, and resale value of the car.
So now you are shopping to buy a company. Not a whole company, but just a tiny share of it. But you are still paying your hard-earned cash to buy a piece of it. So you want to make sure you are not overpaying for it. Better yet, you want to actually find a company that you believe is a bargain, i.e., is selling for less than what you think the value of the "features and specs" of the company. Some of those specs include the amount of assets it has, the revenue it generates each quarter, and the amount of debt it has. Moreover, you realize that some companies have certain features and specs and a reputation / management team that make them likely to have higher "resale value" in the future, but unlike cars, you can even expect appreciation in value. So you would spend even more time worrying about "resale value" than in the case of cars. Finally instead of paying regular maintenance costs for a car, buying a company allows you to have a positive cash flow (aka dividends) each quarter. So you would also weigh that heavily into your decision.
So after all this analysis, you finally find a company that you think is selling for a bargain and you buy it. Then all of a sudden, one of the features of the company actually gets better than the time you bought it, e.g., it's revenue increased by 20% this quarter.
So anybody who is now planning to purchase this company will be willing to pay even more for this company than the price you paid, because it has better specs than the time you paid for it. So the price will rise, and you will have an unrealized gain in your pocket.
Okay, so you might argue, why does anything other than the positive cash flow influence an investor's decision to buy or sell the company? Well, that I believe is because ultimately there is a finite probability that either (1) the whole company could get bought out by another company, or (2) the company could go bankrupt. If the company gets bought out, then the acquirer will have to figure out the value of the company it is buying because it obviously doesn't want to overpay for it and would like a bargain. In that analysis, the acquirer will also plan for the worst case scenario, what if this company stops making money and starts losing money -- will I be able to "liquidate" and get back at least some of the cash I am paying now? This is where assets and debt come into play.
So in the end all of those things on a company's balance sheet and cash-flow statements determine the value of the company and therefore the price of the stock.