Short answer
The Qur'an compares people without faith to someone in the darkness of a deep ocean. It speaks of waves covered by more waves, with clouds above, and darkness in layers, one above another. A man in that darkness can hardly see his own hand. Nothing in this picture is wrong. Light fades as the sea gets deeper, and below about 200 metres there is almost none. Deep under the surface there are also hidden waves of their own, which many Muslims see in the verse's waves above waves. Scientists first worked out their theory in the nineteenth century. The Qur'an was revealed to the Prophet (ﷺ) in a desert town. He is not known ever to have gone to sea, and no one then could go down into the deep. The verse teaches a lesson about faith, and it is also a sign.
Full explanation
What the verse says
The verse is a parable (a picture that teaches a lesson) about the one who turns from God (﷾). His state is like the darkness of a bahr lujjiyy, a deep, vast sea. A wave covers it, above that wave is another wave, and above that is a cloud. The darkness comes in layers, one on top of another, until a man can hardly see his own hand. The verse ends with its real point: the one whom God (﷾) gives no light has no light.
“Or (the Unbelievers' state) is like the depths of darkness in a vast deep ocean, overwhelmed with billow topped by billow, topped by (dark) clouds: depths of darkness, one above another: if a man stretches out his hands, he can hardly see it! for any to whom Allah giveth not light, there is no light!”
Darkness that deepens
Sunlight does not simply stop at one depth. The sea absorbs it as it goes down and takes out its colours one after another. Red goes first, and it is gone before 100 metres. Then orange, yellow and green go, and blue reaches deepest. So the sea grows darker in stages. There is rarely any real light below 200 metres, and beyond about 1,000 metres the sea is completely dark.
Explains that sunlight fades quickly with depth: it may be detected as far as 1,000 metres down, but there is rarely any significant light below 200 metres, and below that the ocean grows ever darker.
Explains that water takes the colours out of sunlight one after another: blue light goes deepest, then green, yellow and orange, and red least of all. Red light is quickly filtered out as depth increases, does not reach 100 metres, and effectively never reaches the deep ocean.
Waves beneath the waves
Surface waves are not the only waves in the sea. Where a lighter layer of water lies over a heavier one, waves travel along the hidden boundary between them. These are called internal waves. Scientists first worked out the theory of such waves in the nineteenth century. In 1904 Walfrid Ekman, a Swedish scientist, showed that they were what had held back the ship of Nansen, the Norwegian explorer, in the Arctic.
Explains the "dead water" that held back Nansen's ship Fram: where a layer of fresher water lies on top of salt water, the ship's power goes into making waves on the hidden boundary between the two layers. It showed that these hidden waves were real and strong enough to slow a ship.
Defines internal waves as waves that occur inside a body of water, beneath the surface, rather than on top of it.
Why this is a sign
A sailor knows the sea goes dark below him, and anyone can see waves and clouds. The claim is not that nobody knew the sea was dark. The claim is about who received this verse. The Qur'an was revealed to the Prophet (ﷺ), a merchant of the desert who is not known ever to have been to sea. It describes a deep sea with the darkness stacked in layers and waves beneath waves. It says nothing in this verse that later knowledge has had to correct. It is one of several such passages. The Qur'an itself says God (﷾) will show His signs until it is clear that it is the truth.
“Or (the Unbelievers' state) is like the depths of darkness in a vast deep ocean, overwhelmed with billow topped by billow, topped by (dark) clouds: depths of darkness, one above another: if a man stretches out his hands, he can hardly see it! for any to whom Allah giveth not light, there is no light!”
“Soon will We show them our Signs in the (furthest) regions (of the earth), and in their own souls, until it becomes manifest to them that this is the Truth. Is it not enough that thy Lord doth witness all things?”
Perspectives
The Islamic perspective
The parable of the deep sea, revealed to the Prophet (ﷺ), is right in every part it describes. Its purpose is spiritual, and its accuracy is a sign of where it came from.
Qur'an 24:40 describes darkness in a deep sea, in layers one above another. There are waves above waves, and clouds above them.
Sunlight is absorbed as the sea deepens, one colour after another, and there is rarely significant light below 200 metres.
The deep sea has internal waves on the boundaries between layers of water. Their theory was first worked out in the nineteenth century.
The Qur'an's picture of waves beneath waves fits the internal waves found beneath the surface.
The Qur'an gave an accurate picture of the deep sea to a man of the desert. He is not known ever to have gone to sea. This is one of the signs that the Qur'an is from God (﷾).