For Russia there is a lot of upside to having control of Ukraine. It's an important piece when it comes to combating NATO encroachment, it gives them access to plentiful natural resources (making them an even bigger exporter of grain and fertilizer), it gives them more control in the Black Sea, which gives them more reliable access to the Mediterranean and the Atlantic Ocean.
Compared to not having control of Ukraine, they gain a lot of influence and reach. NATO would love to have Ukraine join, for the exact opposite reason: it would significantly bottle up Russia and put it in a very disadvantageous position in the event of war, which would give NATO considerable advantages when negotiating with Russia.
It's no surprise that the West has invested so heavily in Ukraine; the effect of a Russian victory would be big and would be felt for a very long time. At the same time, if they can hurt Russia through a proxy war, it works out for them, at least for a decade or two.