I didn't properly understand this until I was a hiring manager working with a recruiter, but recruiters often send these e-mails without making any effort to verify that the hiring manager is interested in the candidate. If you don't have a profile that the hiring manager finds immediately attractive, putting you through a coding exercise can be the recruiter's way of building a case to the hiring manager for bringing you in to interview.
I find the whole thing frustrating, too, which is my response to all of these canned e-mails (unless I'm totally disinterested or I'm really actively looking) is, "I'd be happy to take a call with the hiring manager to discuss the position." If they're really interested, they'll take the call, and if they're not, I haven't wasted my time.