Even if spirituals and other forms of music weren't always full of coded meanings about secret houses (and it stretches the imagination to imagine that they always, or even often, were) they still might represent a form of resistance. Modern historians of slavery recognize everyday activities as forms of slave agency, by which they mean the ability to control at least a small part of their own lives. Slaves who sang songs whose meanings were not clear to their owners were, in a sense, exercising a form of resistance. The grim reality of slavery was that for most slaves, running away or fighting back were not realistic options given the potential consequences. But this does not mean slaves did not resist. Historians recognize slaves who broke tools, worked slower, exercised control over their own sale, preached to other slaves (or listened to slave preachers) and many other activities as a form of agency, even if these actions would not lead to their freedom. Slave music certainly fits in this category, and has been the subject of numerous studies of slavery in the last half-century.
I agree with the previous posts but especially number 6. The spirituals were a means of communicating where safe houses were located, who would help them in their attempt to escape, and how to contact those safe houses on their way north to freedom. As any captive population will, the slaves found a way to communicate with each other without the boss man being any the wiser. Because they were sung openly and in a working rhythm, the supervisor left the songs and singers alone, allowing the slaves a rather safe form of communication.
It did serve to lift spirits and such, but it also served as a coded language. Many of the old spirituals were also freedom songs. Information about escaping or running away was transmitted in the song, in the clapping, etc. Music was part of the language code that allowed enslaved people to talk to one another without fear of being overheard or "found out."
Music is at the core of the soul of many, many African-Americans, who most easily express themselves with song such as gospel music, blues, and jazz. The spirituals which they sang in the fields as slaves served as an expression of their situation and its accompanying emotions. The spirituals which compared their plight to that of the Israelites in the Old Testament, slaves were encouraged to endure. Also, such songs as "Ain't No Ways Tired," for example, allowed the oppressed both an outlet for expression and inspiration.
In Brazil, the story goes that African slaves used music as a cover for practicing an original martial art: capoeira.
As I've heard the story, the open practice of martial arts was outlawed because slave owners did not want their forced labor to know how to fight. So the slaves of Brazil developed a rhytmic style of fighting that looked enough like dancing to fool the slave owners.
It hid violence in dance, and trickery and cleverness in playfulness.
In capoeira, music is played as an accompaniment to the practice of the martial art.
Music was a religious activity, but it was also a connection between people. If you listen to the old slave spirituals, they are not only hauntingly beautiful but also often downright inspiring. The people might have been slaves, but music was something they could own.
I would imagine that music played a few roles for them. These would include entertainment -- music could be a way for them to relax and enjoy themselves in their free moments. It could also be a way of getting through the hard work of the day. Finally, it could have hidden meanings that would make it something of a way of resisting the masters' oppression.