Ukraine gave up nukes that they couldn't afford to maintain and got unenforcable security guarantees 'assurances' in return.
Giving up the nukes allowed Ukraine to attract foreign aid and build an economy for 20 years before invasions began. Who knows what would have happened if they kept nukes and didn't get necessary aid and couldn't build their economy or maintain the weapons.
I think the point isn't if it's been a good decision at the time (I don't think it's been much of a decision at all), but rather that Russia wouldn't have invaded Ukraine, if Ukraine was still armed with nuclear weapons. Hindsight is 20/20, but the world took notice.