A "unit" isn't necessarily residential. There are mixed-use "units" on the market that might be used as homes or as offices/shops.
A "dwelling" mostly comes up in the contexts of censuses and elections. One census form needs to be filed per "dwelling", and should include information about everyone who has dwelled there for the majority of the last year. This includes, for example, people just crashing on the couch, even if they're just on vacation and "live" somewhere else. For another example, this includes homeless shelters: the people staying in them can say the shelter is their "dwelling", though they're unlikely to feel like it's their home. (Also, a "dwelling" is not necessarily residentially zoned. You might be dwelling in a storage unit. It's not necessarily legal, but the government still needs a word to describe "places people live" that includes such cases.)
There's also "residence", which is just "dwelling" in fancier clothes, though usually implies residential zoning.