Was about to ask how the math works, when I stumbled over the worlds shortest (and logical) explanation: "Speed reduces quality."
So if you want to improve quality: do not use speed mods. Lesson learned. ;)
PS: And another reminder... Epic & Legendary quality levels are unlocked under the Gleba branch of the research tree.