The shape of a molecule is determined by the number of electron pairs in its outside shell and whether these electron pairs are bonding or non-bonding.
The Valence Shell Electron Pair Repulsion (VSEPR) theory is used to explain this.
Think only about the central atom of a molecule eg the C of CH4.
Spread the electron pairs of its outside shell around the surface of a sphere. They should be spread out as far as possible.
Since non-bonding electron pairs are held closer to the central atom than the bonding pairs, the non-bonding electron pairs repel the other electron pairs more than bonding electron pairs do.
The way this works is best shown by examples. Check your A-level specification to find out which shapes you have to KNOW and which ones you need to be able to WORK OUT.
Start with two electron pairs, both bonding (eg BeCl2). The electrons spread to opposite sides of the imaginary sphere and so the molecule is LINEAR with a bond angle of 180o.
A third electron pair (eg BF3) gives a TRIGONAL PLANAR molecule with bond angles of 120o.
Four electron pairs might be thought to give a "X-shaped" arrangement but it turns out that a three-dimensional arrangement works better. The electron pairs point to the corners of a regular tetrahedron. A tetrahedron is a pyramid-like solid with each of its four faces being an equilateral triangle.
If the electron pairs are all bonding, then the shape is TETRAHEDRAL with a bond angle of 109o28'.
If one of the electron pairs is non-bonding, then the shape (defined by the positions of the atoms rather than where the electron pairs are pointing) is known as PYRAMIDAL. The bond angles are approximately 107o for ammonia. The reduction from the tetrahedral angle is because of the extra repulsion of the non-bonding electron pair.
If two of the electron pairs are non-bonding, then the shape is known as BENT (or ANGULAR or DIHEDRAL). The bond angles are approximately 104.5o for water. The even-greater reduction from the tetrahedral angle is because of the extra repulsion of two non-bonding electron pairs.
Five electron pairs leads to a TRIGONAL BIPYRAMIDAL structure if they are all bonding (eg PF5).
Six electron pairs gives an OCTAHEDRAL structure if they are all bonding pairs (eg SF6).
but if two of the pairs are non-bonding, a SQUARE PLANAR shape is produced (eg XeF4).
What about ions?
Treat ions the same way. Count up the electron pairs around the central atom (remember that the charge will show you that one or more electrons have been added or taken away). Then spread out the pairs as above.
What about if I can't decide which shape?
There are some molecules or ions whose shapes cannot be predicted by this simple method. If this is the case for a question that is set in an examination, credit will be given for you providing a SENSIBLE answer based on the principles discussed above. Remember that you need to know the shapes of some molecules and deduce good estimates of the shapes of others.
eg PCl3 Its shape will be pyramidal but although you should be able to work this out and predict that the bond angle is a bit less than 109o28', you cannot say exactly what the bond angle is. An answer of "less than 109o28' is not very good because that could include something ridiculous like 36o, but saying "between 106 and 108o "would be fine, as would "just less than 109o28'".