Yeah, this is not definitely attributed to Keynes, and earlier verions of it by other people paint this in a slightly different way as a positive point, that even nasty people work for the benefit of all. Many versions have been attributed to Keynes, both as a positive and a negative for capitalism.
https://quoteinvestigator.com/2011/02/23/capitalism-motives/?amp=1