God created a universal law to balance all things. God is in control even as man's free will comes into play.
Jonah knew that it was his fault that the calamity came about. Apparently he had enough love in his heart not to want the others to suffer for what he had done and so was willing to sacrifice his own life to save them.
At the same time God knew the hearts of the others on board and His will was involved as they were being taught to have faith, while being motivated by a life and death situation to seek Him. They then exercise their free will to come to God or not.