Several reasons. First, the NCAA requires that schools have a minimum number of athletic programs to qualify for participation. For FBS, it's sixteen, with a minimum of two of each gender for Fall, Winter, and Spring seasons.
Additionally, the athletic department's historical role is not just revenue from football and basketball (good thing, because historically, most schools lost money even on those, particularly football). Competitive sports draws not just athletes, but students to a university, making them a part of the university's brand. That matters for recruiting students more broadly than athletes, which translates into all kinds of good things for the school. A person I'm close with spent his life helping small and underperforming schools increase their enrollment. One way to do that was to become good in a niche NCAA sport. The one that sticks out to me was rodeo. One of the schools he worked with in the western states focused on having a great rodeo program, not because the program would make money, but because it would become a draw for non-athletes as part of the brand of the school.
Frankly, this is how Notre Dame became a great school (not football program)--by leveraging its football success to attract more and more students, making it more competitive, turning it into a great university in addition to having a strong football program. The same could also probably be said about Michigan and Ohio State (and many other B1G schools).
So, as part of that history, the athletic departments created and maintain sports programs that maybe they wouldn't start today. Example: Washington has a history of having a strong crew team, so Washington cares about crew.
Some schools--many, actually--also care about their standing among collegiate athletics, again, as a selling point, beyond the revenue sports. Stanford doesn't spend enough on football to truly be competitive, but it likes winning the Director's Cup, so it keeps 36 athletic teams (for reference, Michigan has 27, Wisconsin and UCLA have 25). That's also why Stanford routinely wins the Director's Cup: it has the most teams. Alumni (and probably students) at these schools like those programs, so they don't want to see the universities drop them.