No, it is because some people have worked at very impressive jobs and probably just clack on keyboards all day and actually did nothing while there, so when you hire them you learn that they actually can't do the job you hired them for. You just can not rely on the CV alone.
In the hiring process there has to be some kind of skill test. If it is not a "homework" then it has to be a whiteboard/live coding/system design type of interview and there are a ton of problems with this type of skill test as well.
We usually give people the choice which route the candidate would like to do. Take a 1 hour interview or a "homework" assignment which took me about 1 hour to solve. Which is probably best because some people really prefer the homework because they get nervous in interviews.
> Will an attorney give you free legal advice until you decide they are fit to represent you, or will you get free surgery until someone proves they won't completely butcher you?
I do not know how attorneys or surgeons are hired, but my guess is that the education side of these jobs lines up much closer what is actually needed to do the job (which isn't really the case with Computer Science) and that when they claim to have done X or Y then it was actually them in court or at the operation table and not someone else from their team.
Clients select their attorney based on reputation of the attorney or the law firm they work for. For Surgeons it is probably similar. If you have the choice you want to go to the hospital with the best reputation. If the company you apply to already knew your name and reputation beforehand then the skill test is probably also not necessary, but that is not usual in my experience.
It also probably helps that both of those jobs require a Professional License to practice these jobs. Maybe if the software industry introduced a Bar Exam then these "homework" assignments would not be needed anymore.
> Can you drive a car for free (for 5 - 8 hours) until you decide that's the car you want to buy?
Usually you can. At least in my experience. Not fo 5-8 hours of course, but long enough to know.
If you know of a better way to hire people: I would be happy to listen.