We live in an apartment that has a lot of gaps in the doors and windows and poor insulation in the walls. Is there a way to make the landlord fix this? Some sort of property codes or something? He doesn't seem to want to fix it on his own. We live in San Francisco for what its worth.
This is the classic agency-dilemma,or principal agent problem.
THe one who should bear the cost, the landlord, doesn't see any immediate benefit; and any indirect benefit may be, or be believed to be absent. The landlord should bear the cost because, at least in theory, in a well-functioning market, a landlord would be able to earn higher rent on a well-insulated apartment. The one who benefits is the tenant, who gets the warmer, more comfortable apartment, and lower heating bills.
So, the cost is to the landlord, the benefit is to the tenant.
There are at least four ways out of this.
The best way, at the macro level, is to get your municipal authority to introduce landlord licensing, and allow only properties that are well-insulated to be rented.
offer to share the costs of insulation with the landlord. Perhaps you know someone who can do the work to a high quality cheaply, or you can source cheap materials, or you'll redecorate after the insulation is done. Or if you've got a guaranteed tenancy for 5-10 years, and expect to stay there that long, pay for it yourself.
offer to share the benefits of insulation with the landlord. So once the insulation is in, you pay more rent.
Many municipal authorities do have some controls / regulations on rented properties. The type of regulation, and (crucially) the level of enforcement, varies hugely. But in many places, there are regulatory standards that say a place rented for habitation, must be habitable. If you have a relatively enlightened authority that has the resources to enforce such a regulation, then you may be in luck. First find out which department would be responsible: in England, it would be Environmental Health. It may be Housing, or something else, where you are. Talk to local tenant-support organisations, and local environmental groups - they may know of successful precedents.
There isn't likely to be a way to require him to do anything. You'll have to try tact.
Maybe offer to do the work yourself, if he buys the materials. He'll be glad to have his property improved, as long as he trusts you with the work.