Studies demonstrate that recalling information you learned recently increases the chance that your brain saves the information in long-term rather than short-term memory. The idea is that homework reinforces the information learned in class allowing you to remember it come test time and after the course is over. I've had courses where the homework is completely unrelated to the course material, that I find a little less effective but it still has its merits -learning material outside of class in order to cover more in the course-. Overall, I'd say homework is helpful but can be used poorly by some professors/teachers.