Type 1 is a autoimmune disease where the body identifies the islets located on the pancreas which are responsible for insulin production as something that shouldn't be there. So the bodies immune system destroys them, leaving the person without the ability to produce any insulin so injections are required.
Type 2 is caused by insulin resistance, meaning your body can not effectively process the insulin your body is producing. This means your pancreas has to work harder to produce more insulin. The pills are designed to help your body more effectively use the insulin you are already producing. Some type 2's need insulin injections to top up the amount of insulin in your system if you aren't producing enough for the pills to be effective.