It is often said that a person's consciousness at the time of death determines their next embodiment.
Bodies can be said to be kinds of consciousness: a soul embodied as a dog has dog-consciousness, a soul embodied as an elephant has elephant-consciousness etc.
The other day I saw a flower with many insects on it, mating. Seeing that made me think that perhaps if someone wants to have a lot of sex and not take care of the offspring, then a kind of insect is the body to have.
And I swear many people in various "yoga centres" doing some fancy exercises will be born as bacteria, given the consciousness they practise there ...
The principal behind taking different bodies is karuna guna-sangasya sad asad yoni janmasu (Gita 13.22). The cause is due to associating with a particular mode. Prabhupada quotes this verse very often in his classes.