Why was the Ego (nafs) created?

Why do we have an ego?