Forgive me if this has been said already, but I didn't see it in the above answers (might have missed it). I think the importance for houses, besides the initial reason for the founders wanting to teach specific kinds of students, and promoting competition, is what Mcgonagall says to them in the Philosopher's Stone. "She says that the houses will be like your family"
It's important in a boarding school that you still have a "family". Your friends are more than just your friends, they are like your brothers and sisters, and your head of house (in Hogwarts, at least), is like your stand-in parent. They mentor you, discipline you, etc.
https://www.boardingschoolreview.com/blog/teaching-in-a-boarding-school
In the first paragraph, they say
Boarding schools are self-contained communities. Students and faculty eat together. They share relaxing times watching TV and playing games together. That is because teachers and staff in a boarding school function in loco parentis. They take the place of parents literally and figuratively. They play a powerful role in shaping and guiding their young charges while they are at school. Because the students cannot escape at the end of classes, they cannot avoid the strong influence teachers have on them
and so sorting based on traits helps foster this familial relationship. You are putting like-minded kids together who are most likely to get along. Malfoy and Harry, for example would probably have never gotten along due to cultural and personality differences. My evidence is that before Harry was even sorted, he did not like Malfoy. It also helps build strengths like others have replied.