As I understand it, it's supposed to be illegal for anyone to ask for your SSN other than for Social Security purposes. Your employer is an obvious exception because they pay social security taxes on your pay.
However, it's a muddled issue. Laws change, and the law that prohibits the use of the SSN for non SS purposes is rather old but never amended or recinded.
If you challenge places, you often get around it. Even DMVs are pushing for the info, but the matter is you have to go to court (most likely) to get a ruling. Not really expensive to do, but time consuming, and you have to do it before you need your DL or you basically are denied one until the court sides with you and orders the DMV to do without the information.
In today's world, I suspect many courts would force you to give it saying "times had changed."
However, it was the very fear of men being given a "number without which he can not buy or sell" that prompeted the original law limiting the SSN to only SS purposes.