Ashkenazic custom does not allow eating kitniyot (legumes) on Passover. Included in this category are rice, corn and all types of beans. So why are we permitted to eat chocolate on Passover? Isnʼt chocolate derived from the cacao bean?
Although they are referred to as beans, cocoa beans are not legumes at all. They are the edible seeds of the cacao fruit, which grows on a cacao tree (Theobroma cacao). To better comprehend why this is significant, one has to understand why legumes were forbidden.
Historically, legumes were grown next to fields of grain. The five species of grain (wheat, barley, spelt, rye and oats), which can become chametz, would get mixed up among the beans. Additionally, because beans are used to make breads and porridges in a manner similar to the five grains, using kitniyot on Passover can lead to possible confusion.
These reasons do not apply to chocolate. Cocoa is not used in a manner similar to flour, nor is it grown, collected and stored in a way that would cause grains to get mixed in. Because cocoa is actually a fruit and not a bean, the restriction of kitniyot do not apply. However, this does lead to an interesting discussion in the rabbinic literature as to why in fact we recite a shehakol on chocolate and not a borei pri haʼeitz (see Minchas Shlomo I:91).