As best I can tell, Putin thought that Ukraine was about to be admitted to NATO, and didn't want NATO troops on his borders in both the Baltic states and Ukraine, so he invaded to preempt this. It seems to me that the threat of invasion would have worked as well as actually invading, at making NATO uneasy about admitting Ukraine, and would have involved far fewer downsides for Russia.
I have long thought Putin to be a mean but smart individual, but even if Russia eventually accomplishes the conquest of Ukraine, this looks like a blunder on his part, not only a moral error (although certainly also that).