There are plenty of really intelligent people are also just asshats. The one does not preclude the other. I’m guessing Ted was an obnoxious, precocious kid who grew into a dick of a teen and as a fully formed adult is just a real piece of shit. Someday we will discover there is a gene for this.