Why is the 了 here after 错 not after 投?
“投错了险” is an informal expression.
It is generated from the phrase: "买保险“.
the evolution chain: "买保险” →“买错保险”（negative form，“错”here is a "verbal complimentary", which showing the result of an action "买”。）→“买错了保险”加上了tense particle “了”→“买” can be accepted when to be replaced by "投” in a context of a casual email. "保” of “保险” can be omitted too in this context.
"le" has to be put after "complimentary". So, 投了错的险 is wrong.
why people use ＂投” instead of "买”？ In recent years, more and more people changed idea of buying insurance for accidents to a type of investment. And "investment" in Chinese is “投资”。 So some people say "投保险“。—— I personally don't like it. This just shows how people become careless about the use of words instead of using innovative new words.