The Heartless are born from pure Darkness itself. When a heart is stolen or consumed with hate, the darkness inside it consumes the heart, forming a Heartless. The body and soul then form what is called a Nobody, if the consumed person's will is strong enough. There are two types of Heartless in the series; Pureblood Heartless, which are born directly from hearts, and Emblem Heartless, which are born from a machine that collects darkness and can artificially recreate the heart-stealing process.
Ansem the Wise, ruler of Radiant Garden, studied the darkness of the human heart. These experiments were carried on by his six apprentices, mainly Xehanort who went on creating Heartless.
The Ansem Reports can be collected by Sora throughout his two main adventures. They were written by Ansem who only penned Ansem Report 0 with the rest written by Xehanort under his name and the first twelve reports contain information on the Heartless with the last page containing brief information on Nobodies. In Kingdom Hearts II, the Secret Ansem Reports written by DiZ contain information on Organization XIII as well as expanded information on Nobodies.
After Sora saved the Princesses of Heart in Hollow Bastion, his heart once turned into a Heartless until Kairi changed him back to normal.
Ansem's six apprentices aided in the study of the hearts, these being Ienzo, Even, Braig, Dilan, Aeleus, and lastly Xehanort. After Ansem was exiled by Xehanort, Xehanort took his former master's name and led the other apprentices in deeper studies of the heart. This lead to him corrupting the others and releasing their hearts, thus all of the apprentices became separated between their Heartless and their Nobodies, which formed the group Organization XIII. It was Xehanort who also (while disguised as Ansem and as the Seeker of Darkness) designed the Heartless Machine that manufactured Heartless.