Under international law, you are the custodian of your own passport and you do not need to surrender it to anyone except a lawful authority. I think Qatari law is clear on this too. There have been many cases in the paper where employers would keep worker passports and if the workers complained to the government, the courts rule in their favour. The only exception might be if the worker has no safe place to store their passport, but even then they should be able to ask for it back at any time and the surrender should be voluntary.

Employers of course like to have the passport as a way of controlling their indentured servants. You can't escape the country without an exit permit anyway, but you can't even escape your employment if you know you will have to come back sometime and beg for your passport.