Why does Spence infect the Hive at the beginning of the Resident Evil?
Spence's reasoning behind breaking the vial (at least according to the film's official novelisation) was that the Red Queen would detect the virus in the air in the Virus Room, causing the Hive to lock down. This would substantially delay Umbrella from finding out that their virus had been stolen and give him lots of time to make a clean getaway. As an added bonus, his actions would almost certainly cause some infections and fatalities, leading to a cover-up from Umbrella.
Unfortunately, Spence was unaware that the Red Queen was rather more efficient (and aggressive) than he'd anticipated. His actions spread the virus through the Hive very quickly, due to the advanced air conditioning system and she triggered the lockdown before he'd had a chance to make good his escape.
He removed the Hazmat suit, put on a pair of rubber gloves, and entered the keycode. The case obligingly opened, an action that served two functions: to verify that the keycode worked and to allow Spence access to one of the vials containing the blue liquid.
Pulling out the vial with a protected hand, he sealed the case once again, placed it in a duffel bag, zipped the bag up, and hoisted it onto one shoulder. Before departing the lab, he tossed the vial toward the center of the room, then turned, exited, and closed and locked the door.
He had to move quickly now—he had maybe five minutes before the Queen would lock down the place. It took two minutes to make it to the train station level.
Spence Parks intentionally infects the Hive to cover-up the theft. Umbrella is a way big organisation and his intention was to sell the virus to the black market, so by making the virus outbreak he tried to cover up what he had done. He obviously didn't expect the full potential of the Red Queen.