A real estate investment firm has paid nearly $6 million to acquire a 107,000-square-foot office building in Somerset County, where it now plans to spend another several million on upgrades.