It's because the type of f is not (String -> String) -> String
It is (String -> Identity String) -> Identity String
Do a replacement manually and you'll see that f has to be of type -> ContT String Identity String --> ContT (String -> Identity String) -> Identity String)
You can see that in the error message Expected type: ContT String Identity String, Actual type: ContT Char [] String. The reason why it looks weird is that it is assuming that your monad instead of being identity is [], and that the r in "m r" must be a Char in order for that to work. I'm not really sure why it chose list, probably type defaulting rules.