The standard for what is patentable subject matter in the United States is "anything under the sun made by man" that is new (novel), useful, and non-obvious. Similar standards for patentability apply in Japan and the European Patent Office (EPO).
Under US law, a claimed invention is deemed useful if, at the time of filing, it is capable of providing some identifiable benefit (to a person of ordinary skill in the art of the invention). The benefit must be specific, substantial, and practical.
Generally speaking, there are three broad categories of patentable subject matter: processes, machines and articles of manufacture and use.
A process could be a method for making something, a method for using something, or a method for doing something. Processes include business methods, most software, medical techniques, sports techniques and the like. Machines include devices and apparatuses. Articles of manufacture include mechanical devices, electrical/electronic devices and compositions of matter such as chemicals, medicines, DNA, RNA, etc.
However, laws of nature, physical phenomena, and abstract ideas are not patentable. Software inventions implementing algorithms are not patentable for this reason unless it produces a "useful, concrete, and tangible result" (US law) or technical effect (European law). The US standard for the patentability of software is more liberal than that in Europe. Japanese patent law lies between the US and Europe.
The patentability of software (and business methods) is quite controversial from a global perspective. Case law in the United States permits patents for software and business methods. Yet computer programs as such are not patentable in Europe, although some inventions that use software can be patented in Europe.
Patents related to natural compounds (e.g. items found in rainforests) as well as medicines, medical treatment techniques, and genetic sequences are also controversial. There are significant country-by-country differences in handling these subject matters. For example, in the United States you can get a patent for a surgical method but you cannot enforce your right to exclude.