Students are a distant second.
Cheers!
Actually, at a lot of schools, their main job is to pull in grant money.
The extent to which these research programs are 'profitable' to university is greatly exagerated. Yes, they increase overall revenues, but they are heavily supported by cross-subsidies.
A university may make a big deal in a press release about a new $1 million dollar grant where five faculty are going to work on a project for 3 years. However, little or none of that grant will support the basic salary of the faculty members who are working on it. The money will be spent on graduate students salaries, lab equipment, travel, and extra summer salary for the faculty members. If the five faculty members are earning $100,000 annually with 30% fring benefits and they are spending 1/3 of their time on this project, then the university is spending about $650,000 on faculty time which isn't charged to the project. That's before factoring in the lab space, secretary time and other factors needed to support the projects.
Yes, the university is increasing it's overall revenue by winning that grant. But they are accomplishing it by diverting resources that were originally intended for teaching. If Wal-Mart was evaluating a new revenue producing idea, and it turned out that it required keeping the customers waiting in line with the cashiers left their cash registers to do something else, their accountants would factor in that cost. Universities don't.