Ukraine joining NATO would have left Russia pretty vulnerable because of the terrain. I think Putin has wanted to annex it completely for a long time in order to avoid being in a very weak military position. If anything shows how vital that region is, it's the extent to which NATO has helped Ukraine, once they realized that the Russian army was in rough shape and could be substantially weakened, if not outright defeated.
As for how long it goes, I think it will last a couple of years. Putin cannot lose this war or it is the end of him. Zelensky is in a similar spot, since he has made it clear that he will not negotiate any terms that do not include Russia returning any land they are holding. NATO would be in a pretty nasty spot if Russia takes enough territory or wins outright. I don't see a negotiated settlement until there is no more will to fight, which will likely only happen once one or both armies are ground into dust.