Because "how do we know you didn't copy paste it from a tutorial and claim it as yours?"
It is insulting, and frankly discouraging. As if the only one true way to tell whether you know your stuff or not is to check if you can solve some silly riddle/puzzle under the gun.
One solution is to only apply to companies without a broken hiring process, but sadly they're very rare.