Well first off you have the national "militia" aspect. Its hard to try and take over a country, especially one that doesn't have a whole lot of resources, when they have roughly 500,000 people all with rifles, ammunition, and military training, among the civilian populace. Add to that the fact that Switzerland has a natural advantage in topography, if the going gets tough they can always retreat into the mountains, and you have a very attractive way of staying neutral.
You cannot also negate the fact that Switzerland is the banker to the world. You attack Switzerland you lose all of the assets that you have stored in Switzerland's famous banks and vaults.
Of course this is not to say that there were never plans drawn up to deal with the Swiss via an invasion. The most recent plan was the Nazi
Operation Tannenbaum which was devised in 1940 to deal with a planned invasion of Switzerland. The Swiss feared that something like this might occur so they created the
Reduit strategy under the counsel of Swiss General
Henri Guisan.