Every creature on this earth is created by God for some purpose. Worms play a very important role in maintaining ecological balance. They loosen and aerate the mud and bring up fertile, nutrient-rich soil. They turn organic garbage into organic fertilizers. Their bodies provide proteins.
Thus, though they are so small, they play a huge role in maintaining ecological balance, and this is the purpose for which God created them.