In the pursuit of knowledge, Xehanort, at the time calling himself Ansem, willingly gave his heart to the darkness, creating both his Heartless and his Nobody, Xemnas. His Heartless was able to retain selfhood due to Xehanort's willing abandonment of his heart. With legions of Heartless at command.