Frankly? no ones actually knows for sure. What we do know, is that due to some reason the immune system of certain people, regard several non-harmful substances (e.g. peanuts, antibiotics, bee's venom) as an enemy and learn to react to it.
This tendency to develop abnormal responses to substances other people don't response to is called "atopy". It has a very strong genetic basis (i.e. it runs in families), and also depends on other factors such as the exposure to infections and the pattern of exposure to the allergen (the substance that causes allergy).
It's a very wide subject, far beyond the scope of my answer, so you may read more here:
http://www.nlm.nih.gov/medlineplus/allergy.html