Beaker isn't that stupid, he can be pretty wicked at times.
I think Beaker came from, yeah, insecurities, more specifically the part of Richard that wasn't necessarily understood. But I don't think he was working through these insecurities, I think he was celebrating these insecurities with a memorable character.