Changing laws may not change some people's hearts, but it DOES change all people's behavior.  Often change of heart comes after a change of behavior.
If the laws that ended segregation were not passed, I have no doubt that there would still be many places where African Americans had to drink out of separate water fountains.  At the time that such requirements were lawful, many white children grew up, believing that this was right.  Precisely because of the change in laws, there are probably no children growing up in the US, believing that this is right.  
Changing laws is an integral part of changing society.