“A bolt from the blue” is a bolt of lightning from the clear, blue sky.
Such a phenomenon is, at least, unexpected and is also startling. Thus the news of the Japanese attack on Pearl Harbor was a bolt from the blue, in the figurative sense.
Literary record of the use of the saying dates only to 1888, but it is likely that it existed in common speech many years earlier.