Soak beans in water to cover by 3 inches for 8 hours or overnight.
Drain and place in a large soup pot along with bay leaves and enough fresh water to cover beans by 2 or 3 inches. Bring to a boil, reduce to a simmer, cover, and cook until beans are tender, about 2 hours.
Meanwhile, make the sofrito: In a large skillet, heat olive oil over medium heat. Add bell peppers and cook until softened, about 5 minutes. Add onions and cook until tender, about 10 minutes. Add garlic, oregano, cumin, and salt to taste, and cook 2 minutes.
Puree sofrito in a blender (in batches). Add sofrito and sugar to pot with beans and simmer for 20 to 30 minutes. Stir in sherry and season with salt to taste. Remove bay leaves. Serve topped with red onion and cilantro.