Difference between "purpose" and "goal"

What does this sentence from Star Trek: The Alternative Factor mean?

Jim, madness has no purpose ... or reason ... but it may have a goal.

As far as I know purpose and goal are synonyms. How about this case?


Solution 1:

A goal is a concrete eventuality you're trying to accomplish, while purpose implies a broader, more abstract teleological drive. The speaker is basically saying that crazy people may be trying to do something, they just aren't doing it for a reason. Which is ridiculous, but sounds portentous when you formulate it bombastically enough.

Solution 2:

I think of purpose and goal this way:

Our goal is to get in and get out without being seen.
Our purpose is to rescue the prisoner.

My goal is to get to the finish line first.
My purpose is to win the race.