This expression has it's origin in medieval England when the Knights were sent by the King to collect the annual rent for the use of the King's land.
Most of the King's Knights were good honorable men and when they came into the town to collect they were welcomed and made to feel comfortable and given nice accommodations. They were good and were treated as such getting the best food seasoned with herbs and spices.
Now the bad Knights were known as the ones that not only collected what was rightly due the King but also extracted additional money, goods, or spices for themselves. They were not respected and once they entered the town they were given the basement to sleep in which was usually smelly, damp and uncomfortable. The peasants did not want these unwelcomes staying around.
When it came time to feed the bad knights they were not given the best food but the worst part of the animal carcass was used which was usually the "cold shoulder". This was a sure sign of being unwelcome in the community.
Now you know the story of how we use the term, "cold shoulder".