Negative experience gain is mechanic to discourage the player from doing something considered bad by game designers. Typical actions that could be giving negative exp:
1.Attacking players within safe zones or without pvp flags.
2.Killing lower-level monsters which character outranks heavily.
3.Killing allied NPCs(if allowed) or fellow players.
4.Failing quests.
5.Idling in town or general lack of activity.
6.Using chat.(discourages spam/gossip)
7.Dying/resurrection.(typically handled as percentage penalty). Dying to low-level monsters/traps counts as major experience loss.
8.Using consumables.(to discourage consumable/potion use)