According to the Biblical story of Luke, the shepherds visited Jesus because they were visited by a group of angels who told them that a messiah had been born in the in Bethlehem, and they visited out of sheer awe and curiosity. However, the visitation of the shepherds is not included in all the Biblical accounts of the birth of Jesus.
It is thought that the inclusion of the shepherds in the nativity may be somewhat symbolic. Luke was a proponent of the poor, and the shepherds would have had resonated more with Luke's audience than the magi of Matthew's account. It would have been considerably more significant that angels announced the birth of poor shepherds rather than wealthy nobility. Also, it is theorized that the shepherds who the angels visited were not just any shepherds and were instead the shepherds charged with the care of the sacrificial lambs for the temple. This would have been very symbolic in regard to Jesus's role within the Christian faith as God's sacrifice for mankind. Although the shepherds are not included in all Biblical accounts of the birth of Christ, many contemporary nativity scenes on display throughout the holiday season depict both the shepherds and the magi as visitors to the manger.