He's not retiring. Good god
There actually was rumors that he was considering it after the Diaz fight. It could be a publicity stunt but it could also be for a number of other reasons.
The reasons why he'd do this, in no particular order:
1. Made his money, doesn't need to risk his health any more. He just saw a guy die.
2. After actually getting beat up in Rnd.2 of his last fight he realized he really didn't like the part of fighting where he got hurt and realized he wasn't as invincible as thought and it was going to happen again.
3. Scared of having to face Edgar, Aldo, Dos Anjos, ect... and realized he won't be able to back up his trash talk. Realized that his wins over Mendes and Aldo, his only really top notch wins, were possibly going to be the highlight of his career and with the reality that he was going to have to face tougher competition he retired to try and retain some ridiculous GOAT legacy before being fully exposed. Now he can just fall back on the "bigger man" excuse.
4. Realized the LW division isn't going to grant him quick KO's after losing to a gatekeeper and can no longer cut to FW with the IV ban and his extra weight, similar to #2 in that he wants no part of the long grueling fights that comes with being at the top of a division.
5. USADA nailed him.
6. Negotiation tactic, losing to Diaz hurt his stock a ton and now he wants to get back some leverage.
7. Injury, possibly his knee, and he doesn't want to "pull out" of his fight. He comes back in a year or two with a fixed knee and a more well rounded skillset.
8. Drugs and partying are more important to him or he can't handle the Hollywood lifestyle and wants get away from the drugs and partying.