Your numbers are off by three orders of magnitude... 1 km2 = 1e6 m2
Yes sorry, I've corrected it now. I thought it was a bit low, I was thinking cubes instead of squares for some inexplicable reason. It is still less than 20% of the Sahara, i.e. there is enough land area in the world (not only the Sahara) that could be used. (The usually cited number is ~3% so I might still have gotten something wrong, if you use 20% efficiency you could halve the area for example, but it's not only PV efficiency you also get losses when you transfer it to the grid.)
How much would that cost?
It almost fits into Saudi Arabia:
This is the entire worlds energy consumption we are talking about, so it's naturally very large figures. But continuing as we are now, building new coal power plants, mining for coal, trucking it around, also cost a lot of money. Coal causes pollution and global warming which is costing us a lot of money continually (and peoples health). Think about how much land will be lost due to sea level rise for example, and that is just one of many problems.
It would be expensive and you couldn't produce that many solar panels over night either. That is why I say we need every option available (solar, nuclear, wind and hydro mainly but probably also energy reduction) if we are going to replace fossil fuels as quickly as possible.