Lots of different views stated on this (which is good!) Personally, at this time in my life I believe that it was a perpetuated policy by individuals and not doctrine. The church simply allowed human error to influence church policy. I think it's somewhat naive to disregard the idea that LDS church leaders were not subject to the social construction of the country through that era of time.
The priesthood was allowed to blacks periodically through JS time and it stopped during BY's time as a prophet. Young was pretty adamant about it and had no issue with members owning slaves, however he stated he personally had no need for it. JS seemed to be on the fence due to many reasons, which aren't quite clear. For the most part, the early church took an abolitionist stance towards it but it's stated in many historical accounts that the church needed to take a more relaxed stance to get along with its pro-slavery Missouri neighbors when the church moved into the area. That mixed with the views of the successors may have opened the floodgate to perpetuating the practice. Again that is just theory though.
There are numerous quotes from prophets and apostle stating their opinion on this very subject, which are very undefendable and laughable*. Brigham Young has tons of them found in the Journal of Discourse. Bruce R. McConkie as well shared his theories in print, which were revised after the fact due to them being somewhat doctrinally incorrect. They only seem to validate this idea. The real shame is how the folklore of why Blacks couldn't hold the priesthood keep living on throughout church discourse (like the "Fence Sitters" comments and the "Decendants of Ham/Cain" among some of them.
Personally? I don't have a problem with it and it doesn't rub me the wrong way (understandably easier said by myself than others) Men on the earth are running the church. It will never be perfect by our fallible nature and unfortunately incorrect practices and policies can be put in place for a time. I'm not disregarding the possibility that it was indeed divinely inspired but in most cases I think the most obvious or easiest answer is generally the correct answer.
An interesting book to read regarding this topic is Black and Mormon by Newell Bringhurst and Darron T Smith. It's a compilation of many authors-LDS and people who are not members of the LDS church.
Aloha