He didn’t purposely sabotage his chances, likely he just caved to angry impulse and lashed out at the SCOTUS without thinking it through. He is very thin skinned.
I've always known the wisdom of the left is tremendously lacking, but Obama's remarks are just downright daft!