It's actually 'dead to rights'. It has been used since the middle of the 19th century to mean 'positively guilty, with no hope of getting away with it'. Hence, criminals were often caught 'dead to rights' or red-handed.
'Bang to rights' is much more recent and American in origin, having first appeared - in print at least - in 1904 in a book about life in Sing Sing Prison. Still, it does mean the same as 'dead to rights'.