Soak the beans (if using dried beans): If using dried beans, soak them in a large pot of water overnight or for at least 8 hours. Drain and rinse the soaked beans. If using canned beans, skip this step.
Sauté vegetables: Heat the olive oil in a large pot or Dutch oven over medium heat. Add the chopped onion, diced carrots, and diced celery. Cook for 5-7 minutes, stirring occasionally, until softened.
Add garlic and aromatics: Stir in the minced garlic, bay leaf, dried thyme, and dried rosemary. Cook for 1 minute more, until fragrant.
Add beans and broth: Add the soaked beans (or canned beans) and chicken broth (or vegetable broth) to the pot. Bring to a boil, then reduce heat to low and simmer, covered, for 1-2 hours (or until the dried beans are tender). Cooking time will be much shorter if using canned beans - about 30 minutes.
Add ham: Stir in the diced ham. Cook for another 30 minutes to allow the flavors to meld.
Season and serve: Season the soup with salt and pepper to taste. Serve hot, garnished with fresh parsley and with crusty bread for dipping, if desired.