The coronavirus pandemic is forcing the fastest reallocation of labor since World War II, with companies and governments mobilizing an army of idled workers into new activities that are urgently needed.

Around the world, former hotel, restaurant and airline staff are moving to grocers, online retailers and hospitals as parts of the economy are shuttered to prevent the spread of the disease—and essential goods and services are strained.

The...