Whimsical means full of or characterized by whims, which are odd ideas that usually occur to you very suddenly. If you decide at the last minute to fly to Europe, you could say you went there on a whim.
Whimsical can also mean tending toward odd or unpredictable behavior. Both whimsical and whim are derived from an earlier English word whim-wham, which is of unknown origin. Whim-wham had about the same meaning as whim, but could also refer to an odd object or piece of clothing.