This Is Not a Leaf

Once on a trip to Spain, I visited an old stone monastery up in the mountains where one of the priests had retired after a long career as a missionary in the jungles of South America. He had a large collection of wonders, among which was a butterfly that looked exactly like a dead leaf. A picture of a similar insect is shown above. I was, and frankly still am, astounded by the faithfulness with which it mimicked the leaf. How did this come to be?

https://preview.redd.it/htcnr6nwic4c1.jpg?width=275&format=pjpg&auto=webp&s=c685dfd48b4766ea411ebcbcddeb70b99a8c928f

It is important to emphasize that I wanted to understand not why the butterfly had assumed a bland color or some other simple trait; rather I wanted to understand how it had come to look designed – with a stem, veins, blotches, a notch.