Allah mentions in a Hadith Qudsi, which literally means that it, meaning fasting, is for Him, because a person is refraining from halal things for such a long time so Allah Himself will reward the person. The slave has left pleasures for the sake of His Lord. What a noble act!
Others say what Allah means here is that this action can have no riyaa in it and this is narrated on Imaam Ahmed (rh). This is because it’s a secret between the slave and The Lord!