Cooking the beans:
Bring the beans, onion, carrot, garlic, thyme or parsley, bay leaf, chiles, and 8 cups water to a simmer in a Dutch oven or other large pot with lid, over medium heat.
Reduce the heat, cover, and cook at a gentle simmer until the beans are creamy all the way through, 50-65 minutes. Alternatively, cover & cook them in a 350ºF oven. The cooking time will vary according to the size and age of the beans. (To speed things up, use a pressure cooker or Instant Pot. If you do, add 1 tablespoon olive oil to the cooking liquid to prevent foaming.)
Remove the thyme sprigs and bay leaf and discard. Remove the vegetables, chop them roughly, and return them to the beans in the pot. Fish the head of garlic out and allow it to cool. Then squeeze the garlic through the cheesecloth into the beans. Season generously with salt.
Serve at room temperature or chilled, topped with freshly ground black pepper and a generous drizzle of oil.
*No time to soak overnight? See options below:
To quick-soak beans: Cover them with cold water, bring to a boil, turn them off, and let them sit for 1 hour before cooking as described above.
To cook directly from dried: Follow the recipe above, noting that the beans will need more water and will take much longer to cook. A pressure cooker or Instant Pot can speed up this process – for example, cannellini beans will cook in a pressure cooker in 30-35 minutes from dry, vs. 6-9 minutes if you've soaked them overnight.