It may or may not have been a whale; the Bible doesn't say exactly what kind of fish it was. It simply says Jonah was swallowed by "a great fish" which God provided for this purpose, and that it spit him out after a period of three days (Jonah 1:17).
Did it actually happen? The book of Jonah in the Bible certainly presents it as a fact, as did Jesus when He drew a parallel between Jonah's experience and His coming death and resurrection (see Matthew 12:39-41). But the Bible also tells us that what happened to Jonah was a miracle, caused by God's intervention in Jonah's life.
Why did this happen to Jonah? It happened because Jonah tried to flee from God. God had told him to go to the people of Nineveh and urge them to repent -- but Jonah hated them and wanted God to destroy them. But God intervened, not only sparing Jonah's life but using him to bring the people of Nineveh to repentance.
Don't reject the Bible's miracles; God is all-powerful, and He is able to work in miraculous ways. The greatest miracle of all was when He sent His Son into the world to die for our sins, and then raised Him from the dead for our salvation. Because of Christ "we have redemption, the forgiveness of sins" (Colossians 1:14).
Most of all, don't be like Jonah and try to run from God. God loves us, and our lives are incomplete without Him. Open your heart and life to Christ today.