Headlight lenses typically can't be replaced on their own, since the lens is molded into the plastic assembly and taking it apart could break it. Because of this, and the high cost of replacing just one headlight assembly, restoring the lens of the headlight is the ideal solution, and there are many ways to go about doing that. Note that these are ways to restore clarity, not to prevent water from getting into the assembly.
There are many kits available from retailers that can do the job with varying degrees of success, ranging from just a single bottle of liquid compound to a kit with all the supplies you need. For a long-lasting result, it is important that you select a multi-step kit that has a UV sealer step at the end. The "all-in-one" bottles may claim to have UV protectants and sealers in them, but since it is mixed in with the chemicals that do the cleaning, the sealer is diluted and very little of it actually sticks to the lens.
Most of the better kits will have a sandpaper step to remove the oxidized foggy layer. Kits may end with that, or end the oxidation removal step with some kind of compound. By this point it will achieve what even the cheapest bottle of headlight restorer can do, but the sealing and UV protection step is what keeps all that oxidation and sun damage you worked to remove from coming back.
Sand & Coat
One of the most straightforward ways is to just sand down the headlight lens in steps, coarse grit to fine grit, and then spray on a plastic-friendly clearcoat. Even if the sanding and polishing isn't perfect, the clear coating will fill in smaller imperfections. The imperfections, in fact, create a surface that the coating can cling to more strongly.
Rubbing & Polishing Compounds
Using a rubbing compound followed by a polishing compound may be an easier method than sand paper, but will still need to be finished with a protective coat afterwards. Scratch remover and plastic restorer compounds can also be used due to being very similar products, but even if they claim to protect, a true coating should still be added afterwards to ensure a long life span.
Ways You Should Not Do It
There are many "home remedy" tricks out there that claim to do the job using household products, but they can range from only a short-term fix to something that actually makes the problem worse.
The toothpaste trick (when using the proper type of gritty toothpaste) can work for a short-term fix, but it doesn't provide any protection at all, so the surface will be even more prone to future oxidation and decay. The grit in the toothpaste acts as a fine sandpaper or rubbing compound, and removes the oxidized layer as it is rubbed in.
Ideally, a protective layer could be added after the toothpaste, but there is no way of telling if the chemicals left behind by the toothpaste will allow a protective coating to bond to it and the lens.
Bug spray is probably one of the worst fake fixes for headlights, since it combines melting plastic with an oily oxidation pore fill. This method will likely result in the oxidation coming back quickly, since the plastic's integrity will be compromised, and runoff due to rain can damage other parts of the car, such as plastic trim and paint clear coats.
Another problem it makes is that when you go use a better technique later, you will have to take off all the bug spray residue, or any protective layer you apply won't properly bond.
This method takes a similar approach to the problem as the toothpaste method (in fact, some toothpaste has baking soda in it) but requires some prep before hand, mixing the baking soda with water to make a paste. If you follow up with the sanding and coating method afterwards, this method can actually last a long time, but since that breaks away from the "home remedy" method and stopping with just the baking soda won't provide lasting results, this falls into the ways not to restore headlights category.
Dish soap has more degreasing properties than car wash soap (which is why dish soap removes car wax but car washes don't) which makes it good for cleaning the headlight before a restoration, but using it as a restorer only works temporarily and on light-duty oxidation. Like with many other home remedies, the results leave the plastic exposed to the elements, and won't provide a long-term fix.
Using a one-step compound doesn't fall into the household item category, but is a poor solution for a similar reason; it leaves the job unfinished. The results may look good initially, but must be followed up with a sealer to keep the headlights looking that way.
Coating with Car Wax
Many of the home remedy solutions suggest sealing the results up with car wax. This will have instant gratification results that look good at the end of the job or in a video, but in the long term, the wax can eat away at plastics, and when the wax wears off, a more vulnerable lens will be exposed to the elements. Wax will work on top of a UV protection coat because the coating isn't plastic, but in any home remedy situation, wax is not recommended.