Alkyl halides are one of the most useful functional groups in organic chemistry. If you can put one on a molecule, there are all sorts of things you can turn it into.
There are generally three different methods to form alkyl halides.
Method 1: Alkyl halides can be synthesized from alkenes. Hydrogen halides, such as HCl or HBr, will add across a double bond, generally in a Markovnikov fashion. This means that the halogen will add preferentially to the more substituted side of the double bond. However, this is not the only product you will form. The downside of this reaction is that the less substituted product will also form in some quantity.

The mechanism for this reaction is addition of H+ to the double bond at the less substituted position. This forms a carbocation at the more substituted, more stable position. The Cl- anion then attacks that carbocation forming the major product shown above. The minor product is formed when the carbocation is formed at the less substituted, less stable position and immediately attacked by Cl-.
Method 2: We can subject an alcohol to a hydrogen halide. Hopefully you have learned that alcohols are very poor leaving groups. Yet, water (or more specifically H2O+), is an outstanding leaving group. We can turn an alcohol into “water” by subjecting it to a strong acid such as HCl or HBr. Once we’ve turned the alcohol from a terrible leaving group into a great leaving group, we can substitute with the halide anion left over.
This reaction proceeds through an Sn1 or Sn2 mechanism depending on what you’re starting alcohol was. Methyl and primary alkyl halides are more likely to go through an Sn2 reaction, whereas secondary and tertiary alcohols will most likely undergo an Sn1-type reaction. Of course, anytime you hear about an Sn1 reaction you need to think about rearrangements, and that can occur in this case too. See below.
One last note, this reaction does not work with aryl halides, only alkyl halides. It also will not work with weak acids even if the resulting anion is a really strong nucleophile, as we can’t create a great leaving group with a weak acid. See below.
Method 3: Radical reactions will make alkyl halides. Using cl2 or br-2, you can form an alkyl halide from an alkane. It is possible to use fluorine or iodine for this reaction, but it is not a useful reaction in the laboratory. Generally, bromine is more selective for the more substituted carbon than chlorine. This reaction proceeds like many other radical reactions going through the three-step free radical mechanism of initiation, propagation and termination.

