Quoting from Bruce Kamich's How Technical Analysis Works:

Support and resistance areas form because market participants remember price levels, and they tend to react as a group when a stock returns to those prices. A simple example will make the concept easy to understand. Let's imagine that you and other investors bought a stock at its initial public offering price of $20. People who did not buy the stock at the offering price are interested in buying it at that level, and they buy the stock at $20 or perhaps above $20 as interest in the stock builds. Other buyers come in and the stock trades up to $22.

The stock may trade back and forth between $20 and $22, but let's imagine that at some point the stock slips down to $16. Some traders will hold on to the stock, hoping that its fortunes will reverse and it will trade back above $22. But if the stock remains depressed, owners of the stock who bought it in the $20 to $22 area will begin to think it would be nice just to break even. If the stock does trade back up, the desire to get out at break-even will become even stronger as the stock approaches the $20 to $22 area.

To put this price zone into perspective, the more sideways trading that occurs, the greater the supply of stock will be. There will be more people who want to "get even," and therefore there will be more resistance to the stock's advance.

Support and resistance are not precise concepts. When support develops during a decline at a price short of the exact level, it is usually because traders are anxious. They remember the prior resistance level at $22, but they start buying on the way down at $22.75 and $22.50 because they are anxious or even fearful they will not have the opportunity to buy again at $22.

On a few occasions, eager traders might push a market too quickly through a support level, and support might not develop until just beyond the support area. Whether support is found short of the expected level or just beyond the level will tell you how eager or fearful traders are.

We have seen that when support is broken on the downside, it then becomes resistance. The opposite is also true; resistance, once broken, becomes support. This reversal of roles is due to the memory of traders and investors who want to get out of their losing trades at break-even, and traders who want to increase winning positions by buying more stock at or near support.

The role reversal of support and resistance leads to the formation of trends, because in an uptrend, market pullbacks or reactions will tend to find support at the last resistance level. In a downtrend, reactions or rallies will tend to find resistance at the last support level.

All support and resistance levels are not equal. The strength of a support or resistance level depends on several factors, such as the number of times the level or area was tested, the volume of trades transacted there, how long ago the formation appeared, and whether it was a round number of a "big figure." Even knowing the type of security will help in determining the validity of the support or resistance area.

The more times a level or zone of prices is tested, the more important that level becomes. A level that is tested six times and holds tends to be more important that one that was tested only twice. The more times a support or resistance level is tested, the more traders will remember it and the more traders will be likely to be committed near it.

When a large volume of trading occurs in a support or resistance area, that adds to its validity because a greater number of traders and investors will remember the level, so their commitment to the level will likely be greater.

The further back in time the support or resistance area was formed, the dimmer the memory, and the more likely that people have already acted on new information and may not respond in the same way again. They moved on by liquidating their positions. An area of support or resistance that was formed recently tends to attract a greater number of people who are still committed to the level. Thus, these nearby levels have more validity or potency.

When a support or resistance level forms at a round number or a big figure, such as $100 or $1,000 or DJIA 10,000, many more people will remember the level because it is easy to remember and obvious. In turn, the more people who remember and act at that level, the stronger the support or resistance will be.