To differ is to have a different opinion, so if you say that you 'beg to differ' it's a slightly old-fashioned, but perfectly acceptable way of politely saying that you disagree with the view of the person who has just spoken.
it sort of means 'I beg (or ask) permission to differ', which is politer than shouting 'You're wrong!' A bit old-fashioned, as andy says - but politeness is a bit old-fashioned.