It is entirely up to the way it is put together. It can be anything as simple as maintenance of common grounds, telling you what you can or cannot do to the exterior of the home, and making certain you keep up with your property and it isn't going to pot so that you are not driving down the property values. There are also different types of associations for condos and co-ops. If you refuse to maintain your end of the deal, the HOA may and usually does have the ability to hire someone to do those tasks on your dime. Which is to say if you don't pay and you try and put your home for sale you will fine a lien placed on your home until do pay for the work someone else had to do to your property.
Okay, but what gives them the legal right to do that?
I don't live in the States, so HOAs here in my country are usually voluntary* - if at all incorporated separately, it would usually fall under the local Societies Act and function much like a private limited company; if you're in it then you're in it, but if you're not, you're outside of their jurisdiction and they cannot compel you otherwise.
*unless, as in the case of serviced apartments, private suburbs, gated developments, etc. which do take fees for security, upkeep and so on.