Russia absolutely did the wrong thing attacking Ukraine. I think it only weakens their position now.
However, these things don't happen in vacuums.
When the Warsaw pact was broken down the West gave promises to Russia that they would not bring ex Soviet states into NATO as it was viewed by everyone as an act of aggression and went against the ideals of de-esculation and demilitarisation of the European continent. The threat of nuclear war was to be averted at all costs and Russia was a partner in that, and not a adversary.
Fast forward and NATO gave membership to Poland, Hungary, Romania, Czech Republic, Slovakia, Slovenia, Latvia, Estonia, Lithuania etc, against their promises to Russia.
Russia did nothing.
NATO openly talked about encircling Russia by bringing in these ex soviet states to isolate Russia. Russian read these white papers.
Fast forward to 2014. The leader of Ukraine was a pro Russian guy who wanted to grow stronger ties with Russia like Belarus has done. The West fermented a coup against that Government and overthrew it and it was replaced with a pro EU government. Russia said fuck that and took over Crimea and the Eastern parts of Ukraine that was majority Russan speaking wanted to break away from the pro West part of Ukraine, and this was in the Dombass region.
Now we end up at a point where Ukraine was asking for membership to NATO, to which Russia said that was unacceptable. NATO and the West said that they didn't intend to bring Ukraine into NATO, but they had said the same thing about Poland etc and went against that. So during these talks Russia asked NATO to agree in writing that they would not give membership to Ukraine, to which they said they wouldn't give that assurance. So, now we have what we have.
So what's the issue with Ukraine in NATO? Well, it puts an admitted adversary of Russia right on their border. It brings nuclear weapons right on their border. Many people don't know that membership in NATO includes "nuclear sharing", where nukes can be put in any NATO country. For instance, there is over 100 US owned nukes in NATO countries pointed at Russia.
Now if the roles were reversed, the West would absolutely have an issue with it. In fact it has happened before. Back in 1962, Russia started building missile bases in Cuba, which would be pointed at the US. JFK was president at time and he went full tilt at Russia and Cuba including naval blockades and threats of retaliation against both Cuba and Russia. It's considered the closest the West and Russia came to nuclear war.
So it's not unfair for Russia to have an issue with NATO enlargement and especially the possible inclusion of Ukraine.
The West and NATO could have avoided this if they agreed they would not bring Ukraine into NATO. They called Putins bluff on it, and they got it wrong.
Does this excuse the invasion of Ukraine? No, not in my eyes. Sure Russia has a considerable issue, but their actions put them in a weakened position I think. I might be wrong and maybe Russia gets what it wants at the end of it. But to me life is sacred, and lives will be lost, and people will suffer. This should be avoided.