Maimonides, Guide for the Perplexed, 3:25

In the whole realm of nature, there is nothing purposeless, trivial or unnecessary.