Yes, we do this to get a Maillard reaction. This basically means we want the onions to go through a complex series of chemical reactions which happen to make a party in your belly. It's what gives a browned food, like caramelized onions their special flavor and color.