The sea is the natural element of the old man, since he has been a fisherman all his life. However, its role is antithetical since it is both a provider and a threat at the same time. Santiago must battle against the elements of nature intrinsic with the sea (storms, extreme heat, attacks from sharks, hunger and thirst) and be found "tried and true." Santiago's experience is on the conflict level of man versus nature, but it is also an internal battle of the will, which he indeed wins - even if he has lost the biggest catch he ever had.
I think for most readers the sea represents nature—but the question is, what attitude should we have about the sea? On the one hand, there is a sense in which the sea, or nature in general, can be seen as indifferent to man. In this reading, the plot of the story is completely arbitrary—there is no reason why Santiago should catch the great fish, nor is there any reason why the fish should be eaten by sharks. Santiago is not “rewarded” or “punished.” He is as much a part of the ecology of the sea as any of the fish he catches.
There is another sense, however, in which the sea functions as test, a challenge to Santiago’s spirit and his “code” as a fisherman. Santiago himself thinks of the sea as a woman:
He always thought of the sea as la mar which is what people call her in Spanish when they love her. Sometimes those who love her say bad things of her but they are always said as though she were a woman. Some of the younger fishermen, those who used buoys as floats for their lines and had motorboats, bought when the shark livers had brought much money, spoke of her as el mar which is masculine. They spoke of her as a contestant or a place or even an enemy. But the old man always thought of her as feminine and as something that gave or withheld great favours, and if she did wild or wicked things it was because she could not help them. The moon affects her as it does a woman, he thought.
It is the “younger fisherman,” who used floats and had motorboats, who thought of the sea as an “enemy” and as masculine, but Santiago saw the sea as a woman who “gave or withheld great favors” according to whim. Santiago has a habit of mythologizing (see his imaginative engagement with “the great DiMaggio’s” bone spurs) and in this case his notion of the sea contributes both to his desire to fish “correctly” and to be worthy of catching the truly big fish. The sea is less an adversary to be overcome than something to be wooed, or tricked, into giving up its treasure. In this sense, the sea is an essential part of Santiago’s moral universe, something against which he is constantly testing himself.