Crying can be both an evolutionary advantage and disadvantage.
In other animals this can be an advantage or disadvantage. If babies can signal to their parents that they need attention, that is good. But if crying inadvertently attracts predators or warns off prey, that is bad. So whether babies crying is, on the whole, an advantage, depends a lot on the particular niche a species occupies in the ecosystem.
Humans are kind of outliers in that human babies are just spectacularly helpless compared to the young of other species. Human babies are born “premature” relative to other offspring. They cannot walk or feed themselves.
However, humans are also apex predators, and are pretty smart and could figure out how to leave the babies at home during the hunt.
The sense of self doesn’t begin to develop until about 6 or 7 months old. So until then the baby acts as an extension of the primary caregiver.