When you spill the beans, you give away private information. If your friend warns you not to spill the beans, it means she doesn't want you to tell anyone her secret.
You might, for example, spill the beans about the surprise party your sister was planning for your dad — and then worry that your sister is going to be furious. While spill seems to have been used since the sixteenth century to mean "divulge," the phrase spill the beans comes from the early twentieth century United States. In addition to beans, early versions had people spilling both soup and guts.