Keep in mind that whales are mammals that at some point in time decided to leave land and take permanently to the sea. When they did they obviously had to evolve some changes to its vision to adapt to see clearly underwater. This they did, and they have great vision underwater. Because they originally lived on land they also, however, still maintain the capacity to see from that perspective and to this day their vision above the water is in many cases just as good as our own.
This notion of spyhopping then is the whales attempt to to maintain an upright or vertical position in the water in somewhat of a treading water movement so its head and its eye is lifted above the surface. From this position it acts like a periscope of sorts and takes in the full field of vision from that perspective. Many types of whales and dolphins can and do make this maneuver and humpback whales that visit Hawaii have been known to maintain this position for minutes on end getting a good peer at the horizon.
Though 99% of what is important to the whale is located underwater this spyhopping capability nonetheless gives it the capability to have a unique perspective on the above water world that most other ocean going creatures cannot experience. Whales can be intrigued by vessels coming out to view them with tourists on board and will often using this technique to take a good look back at the humans looking at it. This technique also comes in handy for Orcas and such that feed on seals that may be on the surface of an ice flow or cropping of land. They may be able to snatch them from the surface if they are too near the edge..