Figuring out which program prevents sleeping is the easy part - there are tools that show that, and you can also usually just brute force it by killing programs one by one.
Then comes figuring out why a system claims to be sleeping but isn't (e.g. the fan is still spinning). Usually this is because of the Modern Standby/S0 crap and in many cases there isn't a solution because the BIOS removed support for S3.
The other class of issue is after sleeping the system won't wake up, or wake up randomly, or wake up with random glitchy graphics/sounds/etc.
Sleep is easily Windows's most bug-ridden area.