
HOAs were created in the early 1900s as private contracts that buyers of homes in certain neighborhoods would have to sign saying that they couldn’t resell their homes to blacks people (and also sometimes Italians or the Irish). I recommend reading Privatopia by Evan McKenzie or Color of Law to learn more.