Proverbially, when there is said to be a method to someone's madness, this expresses that what at first appears to be madness, that is, random, illogical behavior, has a real purpose. It is in fact a method to achieve a tangible goal, with actual thought behind it.
Example: "Mr. Jones talks about the craziest things to people, but there's a method to his madness. People loosen up around him and tell him things they'd never tell most people because they don't take him seriously."
There are surely many, many other examples, but it is best to view the idiom in practice to learn how people employ it.