As stated the question is general, so the answer will be general. Considering you must have a backup to restore, the software just reads the data from the backup file and copies it to the destination drive.
But basically, when you delete something from the recycle bin, it is not permanently deleted yet. It is disassociated (your file explorer on the OS can't find it) but still written on the HDD platter or solid state storage cell. The recovery software scan the disk and find them again. And metadata helps in the discovery of the lost file as well (I don't know how). You cannot recover a deleted file if you overwrite. That is why we shout at people do not write on the disk if they want things recover.