Long term investing is usually based on the principles of 'fundamental analysis', which attempts to determine whether a company's underlying strength justifies its stock price. To begin with, a stock is a 'share' of a company. If you own stock in Microsoft, for example, you have a real and legal claim to a percentage of the assets of that company. The assets might include land, machinery, profits from business operations and so on. Obviously, the more stock you hold, the more of the company you own. In one sense, therefore, the value of a stock should be tied to the value of the underlying assets. In the real world, other factors come into play, including the market's perceptions of the company's prospects.
For example, if the tiny imaginary company XYZ Pharmaceuticals, employing just 100 people, and turning over less than $2 million a year is currently valued at $4 million, what do you think would happen to the share price if the company announced it had invented a cure for cancer? That's right. No extra profits as yet, but suddenly the share price zooms, because the market EXPECTS bigger things in the future. This is one reason why the market is sometimes referred to as the 'great expectation machine'.
Fundamental analysis then, is the study of a stock's features outside of any technical analysis (moving averages, Grail Indicators etc). This might include the perceived economic prospects of a company, the general strength of an entire industry sector, and the state of a company's financial accounts. By focusing on the various statistics in a company's accounts (such as the P/E ratio, cashflow etc) investors believe it is possible to determine if a stock is correctly valued.