The truth is that life is not fair.
You and your manager were playing a different game. While you were spending your time and resources trying to do good for your company and to get better at doing that, your manager was spending time scheming in his own interest and also getting better at it.
He beat you with experience. You were spending your time in Jira and IDE while he was building up his own image, perfecting ways to shift blame and building connections.
And you know what? It is fine. Just ask yourself, "would I want to be that person?"