The shape also has to do with structural integrity. A violin would be of no use if it were built in a shape that would not support the high tension of the strings, thus causing the violin body to collapse after being used for some length of time. Instruments in the violin family, among all musical instruments, are notoriously durable; there are individual instruments that are 300 years old that are still being played professionally.
The shape of the violin, and any other musical instrument, evolved over time through the trial and error of musical instrument builders. In the last 150 years or so, there have been various attempts to apply the science of physics to instrument building and to refine the design.
The Luis and Clark company makes re-engineered, futuristic carbon-fiber acoustic violin-family instruments. They have a FAQ with a discussion of some of the elements of their design; you might find it interesting.