There are many things that can interfere with the soldering process but we can group them into three main groups. The first is oxidation. The second is heat. And the third is perhaps design or human error.
Oxidation occurs naturally with chemical reactions between the metals involved in soldering and the air. Since oxygen is present, it can react with the tin, it can react with the copper, it can react with the lead and form oxides and these oxides have a different crystalline structure that interfere with how the solder can flow and diffuse together to form a proper solder bond. One of the main important parts of getting a good solder joint is to make sure that oxidation is not interfering. A, by beginning with clean material and B, by the proper use of flux.
The second most important cause of failure in a solder joint is insufficient heat. If the solder isn't allowed to come all the way up and above its melting point, parts of it will remain solid, And, while it can flow or be shaped into a soldered joint that looks like it may be okay, it really hasn't had enough energy to go through this diffusion process where the two metals flow into one another at the interface. This is called a cold solder joint and this can be remedied by insuring that the solder has had sufficient heat, it's fully liquid before the heat source is removed, and you can generally tell a good soldered joint by its appearance. It should appear shiny and it should appear smooth.
Now finally, the third main cause of solder joint failure is human error or design error. It's common for many people to use solder as a mechanical connection between parts and in a way that may have some susceptibility to flexing. If the flex occurs it can easily fatigue the joint between the copper and the solder and form a crack, which then lets the pieces fall apart.
So it's important when you're making a good solder joint to make sure that the pieces are going to be held in place and won't be allowed to flex independently of the solder. So either make sure that they're surface mounted to a rigid board or make sure that they're hooked together if you're using wires, for example. But make sure there's some alternative mechanical connection that's above and beyond the solder itself.