This already exists. Its called Pit Stop (
https://sfpublicworks.wixsite.com/pitstop). But they are only open during certain hours, because they require a full time attendant. If these locations were left unattended they would quickly become unusable because someone would either decide to camp out in one, destroy it, or both. The same goes for the permanent public toilets that spread throughout the city.
Additionally most businesses will no allow homeless to use their facilities out of fear. Even if most would be respectful, it only takes one person to disrupt or destroy a restroom and cost business owners thousands of dollars.
But as the old adage goes, you can lead a horse to water but you cannot make it drink. You can provide the toilets, but you cannot make people use them. Many of these people have mental or drug related problems. So even if you provide a toilet, there is no guarantee they will use it.