Q:

Is it allowed to spend a night in the first entry country before moving to the main destination?

I have booked to spend a night in the first entry point which is Germany. Then in the second day I'm going to move to the main destination (Switzerland), where my visa has been issued, by car.Is that illegal and I have to have a flight to the main destination at same time?

A:

No problem at all if you explained it in your visa application.
If you want to make changes to your original itinerary, that is also possible, but then you must avoid the appearance that you misrepresented your itinerary. Having hotel reservations, etc., for Switzerland should resolve this. 

A:

You did your job great. Schengen rules require that you apply for the visa by the main destination of your itinerary, not the port of entry. You applied in Switzerland, you are going to visit Switzerland for the main of your journey. Check ✔
Now, Schengen rules allow you to visit every Schengen country in any order. No one forbids you to stay in Germany even for one night, even for the first night. You can request visa to Switzerland as soon as you can justify it's the main destination.
At the border in Germany, if immigration ask for documentation, you can easily show both of your hotel reservations and they will have nothing to say against letting you in.
When you will be driving to Swiss, you will cross customs but since you are still in Schengen area there are odds that no one will bother you. It is very unlikely that in the event of a police check they will ask for documentation about your visit, since you already cleared immigration to the Schengen space by the German immigration.
A final word about misrepresenting the itinerary. In theory, you could request visa in country A, book a very cheap lodging (e.g. hostel, Couchsurfing...) in country A and at the same time book a proper lodging in country B; then you can get your bogus reservation ready for show-off and hide reservation for country B, by simply not printing/showing it when asked. At the current time, no one is capable of discovering this unlawful behaviour.

