The driver tried to stop the freight train when he saw the labourers on the tracks in the western state of Maharashtra, the railway ministry said, adding it had ordered an inquiry.
Tens of thousands of people have been walking home from India's key cities after losing their jobs because of a lockdown to contain the spread of the novel coronavirus since late March, Al Jazeera reported.
"I have just heard the sad news about labourers coming under the train, rescue work is under way," Railway Minister Piyush Goyal said on Twitter.
Police said the labourers worked for a steel company and were walking to their village in the neighboring state of Madhya Pradesh.
"They had been walking all night, they were exhausted and fell asleep on the tracks," a police officer said.
Because of the lockdown, they were probably not expecting any trains to be moving, an official said.
Under the lockdown, all public transport has been suspended so migrant workers heading home often have to walk long distances to get there.
The government has extended the lockdown until May 17.
The opposition and activists have pointed out that the government has arranged planes to bring back Indians from overseas while leaving migrant workers stranded in big cities with little food or cash.
Prime Minister Narendra Modi expressed his "anguish at the loss of lives" in the accident. "All possible assistance required is being provided," he tweeted.
Rahul Gandhi, the leader of the main opposition Congress party, said he was "shocked by the deaths of migrant workers". "We should be ashamed of how we treat our nation-builders," he said.
Over the past week, some state governments facing public pressure organised trains and buses to bring back migrant workers.
Many are trudging great distances in the blistering heat through fields and forests to get home.
India's railway network is one of the largest in the world and carries about 23 million passengers a day. Accidents are common, with most blamed on poor maintenance and human error.
A 2012 government report described the loss of 15,000 passengers to rail accidents every year in India as a "massacre".