Automatic Weights doesn't work well on a cloth simulation mesh, but works perfectly on a handmade one I have created a mesh using a cloth simulation and sewing, after I applied it, I merged all sewing points and applied an armature deform using the auto weights. It works badly, like this:

After trying everything I decided to try the auto weights with this armature with increasingly more complex meshes until I ended up replicating the mesh manually (magnet + extrude + F) so that I have the exact same mesh, and I applied the auto weighting, and now, it works much better:

Both meshes are the exact same and still, the auto weights work badly on the first one: why does this happen? Is there some king of atribute in the original object which is disrupting the auto weights system?
Thank you for your help!
Ok, so if someone is in the same situation as me, I found a way to make the Automatic Weights work: you must  apply a remesh or some kind of modifier which will change the mesh, for example: I applied a wireframe with very low thickness, merged all verts automatically with Auto Merge, rebuilt all faces with Mesh - Clean Up- Fill Holes; and now it works perfectly. So now you end up with exactly the same mesh, but the Auto Weights will work.
Probably there is a much simpler and sophisticated way to do this, but this way works.