Why residency and domicile status are both needed for tax calculation? Why is just one of them not sufficient?

I want to know the reason behind having two concepts for tax determination. Thanks in advance.