Purpose of creation

People created to be able to learn righteousness
21 O ye people! Adore your Guardian-Lord, who created you and those who came before you, that ye may have the chance to learn righteousness;

(Surah 2, The Cow)