The trailer arrived in Purfleet on the River Thames from Zeebrugge, Belgium, at about 00:30 BST.
Ambulance staff discovered the bodies in the unit just over an hour later at Waterglade Industrial Park in Grays.
The lorry driver, named locally as Mo Robinson, 25, from Portadown, County Armagh, Northern Ireland, is being questioned by police.
Deputy Chief Constable of Essex Police Pippa Mills said the vehicle had been moved to a secure site at Tilbury Docks so the bodies of the 38 adults and one teenager could be "recovered while preserving the dignity of the victims".
She said identifying the deceased remained a "priority" but was expected to be a "lengthy process".
Meanwhile, officers from the Police Service of Northern Ireland have carried out raids on two houses associated with the arrested man - one in Markethill, County Armagh, and another in nearby Laurelvale.
Police said the tractor unit (the front part of the lorry) came from Northern Ireland and picked up the trailer from Purfleet.
The tractor and trailer then left the port shortly after 01:05 and officers were called around 30 minutes later when ambulance staff made the grim discovery.
Police have appealed for witnesses and anyone with information about the lorry's route to contact them.
The National Crime Agency said it had sent officers to assist and identify any "organised crime groups who may have played a part".
A spokesman for the Bulgarian foreign affairs ministry said the truck was registered in the country under the name of a company owned by an Irish citizen.
He said it was "highly unlikely" the deceased were Bulgarians.
-2015: Two migrants were found dead in a wooden crate in a warehouse in Branston, Staffordshire. The crate had been sent from Italy
-2016: An 18-year-old migrant was crushed while clinging to the underside of a lorry in Banbury, Oxfordshire
-2016: A body was found in the back of a lorry in Kent, which had travelled from France
Data was not collected in the same way before the migrant crisis began in 2014, but such deaths are not new.
In 2000, 58 Chinese migrants were found suffocated to death in a lorry at Dover.
In 2015, the bodies of 71 people were found in an abandoned lorry on an Austrian motorway. Police suspected the vehicle was part of a Bulgarian-Hungarian human trafficking operation.
Essex Police has set up a casualty bureau for anyone concerned about relatives to call.
The British Red Cross has confirmed staff and volunteers were helping "those dealing with this terrible tragedy".