Homeopathy works on the principle of the law of similars. The law states 'that which makes sick shall heal' – i.e. a substance which causes particular symptoms in a healthy person will cure those same symptoms in an ill person.
For example, drinking too much coffee can cause sleeplessness, so according to this principle, when made into a homeopathic medicine, it could be used to help people suffering from sleepless nights and the agitation that can sometimes accompany it.
The principle of treating 'like with like' dates back to Hippocrates (460-377BC) who was considered one of the most outstanding figures in the history of medicine. Paracelsus (1493-1541) also worked with the same theory.