The single most important factor in the value of an aircraft (generally speaking) is hours. This will almost single handedly define what the plane is worth. When a plane is built all the parts on it have a life time. This is traced through a series of logs for the plane. When a part is at or approaching its life time it must either be rebuilt or replaced. If you are looking at a plane that has high hours/cycles chances are parts on it will need replacing soon. This is costly to the new buyer and will often reflect in a lower sale price. Here in the US commercial aircraft require more frequent inspections than general aviation planes. These inspections are not cheap and a plane that needs inspection when compared to a plane that just came out of inspection will be reflected in the price as well.
There are of course other factors like wear and tear, corrosion (which can be very costly to fix) and interior condition but generally speaking when large planes change hands they are at least partially repainted with the new companies livery and the interiors are often redone.
For some airlines it may be advantageous to buy second hand planes if they are already flying that make/model. Lets say smallTimeAir flies almost exclusively 727-200's this means they have a nice store of parts for that plane and a crew well experienced in fixing them. It will be easier for them to add another 727-200 to the fleet than say an A320 for which they will need new mechanics and parts they don't have. This makes some used airframes desirable to some people.