To add to Peachey's answer, it's become a stock phrase. Many people use it without being conscious of it as a quotation from Shakespeare. Show a native English speaker "there's a method in my __________" and most will say "madness" instantly, without even thinking.
The most common use is a lighthearted way of saying "this looks crazy, but there's actually a reason for it."
"Here's my way of converting Fahrenheit to Celsius. I start by adding 40. Yes, 40, not 32. I know it seems crazy, but there's a method to my madness..."
However, the phrase is so common that people like to use it as a joking way of talking about _anything_ concerning either methods or madness.