The reason gratuitous promises aren't enforceable by a court is because they lack consideration.
In contract law, for an agreement to be enforceable, there generally must be consideration, which refers to something of value being exchanged between the parties. A gratuitous promise, which typically involves one party promising something without any expectation of receiving anything in return, does not meet this requirement.