After independence, Ukraine had physical possession of a huge nuclear arsenal but lacked the codes and infrastructure to operate or maintain it long-term. The only practical options were to dismantle them, bargain them away, or possibly sell off some nuclear material or technology to third parties — though they ultimately chose to denuclearize under the Budapest Memorandum in exchange for security assurances.
What could have truly deterred Russia was Ukraine’s enormous conventional military inherited from the USSR (actually, the size of Russia's), but it was steadily gutted over the decades through underfunding, corruption, and arms sales.