The answer to 'how to replace recessed lighting' is to carefully remove the old recessed light fixture and install a new one in its place. This involves turning off power to the circuit, removing the old fixture, making any necessary electrical connections, and securely mounting the new fixture in the ceiling opening.
Replacing recessed lighting is a moderately challenging DIY project that most homeowners can complete with the right tools and safety precautions. However, if you are not comfortable working with electrical wiring, it's best to hire a licensed electrician to ensure the job is done safely and up to code.