This looks to be a known problem. See https://github.com/PHPOffice/PhpSpreadsheet/issues/1201 and also https://stackoverflow.com/questions/56855022/how-to-write-macro-in-phpsreadsheet-laravel.
The problem is that a true vbaProject.bin file is actually a binary OLE COM container.
If you create a file from scratch and simple pass a text representation of your vba code, it simply writes the vbaProject.bin file as a text file. This is why Excel reports there was a problem in the file when you open it.
Here is what you could try. Assuming you are reading an existing file (via upload) and then downloading to the user the new file.
Open the file via ZipArchive (a .xlxs/m is actually a zip file) and extract 'xl/vbaProject.bin' and store somewhere (temp file or variable).
Then just before you save the file (for download or whatever) call the $spreadsheet->setMacrosCode() method and supply the binary vbaProject.bin you stored previously.
edit: If you have the time, you can read more about the vbaproject.bin file structure at https://www.decalage.info/vba_tools . You can download the structure documentation at https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/575462ba-bf67-4190-9fac-c275523c75fc