The geth were created by the Quarians to help them for free labor and gave them intelligence over time the geth wanted freedom and defeated the Quarians in war and took their homeworld. The wars between the two forces continued for a long time. The geth were tricked by Saren to help him. After Saren was killed the geth's threat level declinded. Over time the geth focused their resources in to tring to defeat the Quarians again.
Surprisingly, some geth such as Legion known as the True Geth helped Commander Shepard. The other geth were called heretics. Legion convinced many Geth to join the allaince's cause. Sadly, the only way Comamnder Shepard could become the geth's allies was by letting them kill off the Quarians by allowing them to enhance their intelligence or he could let the Quarians defeat the Geth. Either way one race would be sacraficed but, its likely Shepard favored the geth to give tehm a chance to make lives and histories of their own.