Gift-giving is a tradition in Moroccan, and most Islamic cultures. You wouldn't show up at someone's home for dinner without a small gift for the hostess or children. For Eid-al-Fitr, and Eid-al-Adha gifts take on a more celebratory role. In Islamic countries the practice of gift giving during these holidays is largely based on giving children gifts. It makes the event feel festive.
For children who have fasted the entire month of Ramadan (after which we celebrate Eid-al-Fitr) this is a token, a reward for their hard work and sacrifices. I have to admit it's just in recent years that we've started to make the celebration of Eids more of a “big deal” by inviting family over and having small gifts for the kids. Since we are moving in two weeks, my sister has invited us (she's not Muslim by the way) to her house for Eid dinner.