The "creation" of sin suggests sin has a purpose. In response to the original post, my answer is "no", sin does not have a purpose. I assert this claim because God not only because God is perfectly good, but that He is good. The "existence" of sin is not the actual existence of anything; it is the absence of something.
I do not think the analogy is valid.
The good God makes or illustrates from evil does not suggest that God created sin for that specific purpose. Rather, it's an immediate demonstration of God's power who has the capacity to subdue evil for his own purposes. I think the assertion that God's goodness requires evil to operate effectively implies a weakness in His goodness. God is good and therefore good exists as something apart to itself. Evil therefore "exists" in contrast to good, and not vice versa. Why does an all-powerful, all-good, and perfect God require that which He is not to justify Himself?