All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Only those who have the full capacity, namely adults of sound mind, are governed by the religious impositions, among which are the Sunnah traditions and recommended acts. Those who do not have the capacity are not governed by these. The aim of Sharee'ah in advising parents to train their young children at a certain age to perform certain acts of worship, such as prayer and fasting, is to make them accustomed to performing those acts of worship since children at that age are able to perform those acts of worship. However, a baby is not governed by the religious impositions in the first place, and his parents are not enjoined to train him to abide by religious obligations because he is not susceptible to training, unless something is confirmed as having a health benefit for both babies and adults.
The scholars said that the wisdom behind the recommendation to sleep on the right side is so that the person does not fall into deep sleep and thus become unable to wake up to perform night prayers. This is peculiar to adults and not to infants since they do not perform night prayers.
Even if it were assumed that sleeping on the right side had health benefits for babies, but at the same time it were a concern that if the baby slept on his side, he could roll over on his belly with his face down, and this could obstruct breathing and eventually lead to his death, in this case the baby should not be put to sleep in that position so as to ward off the potential harm. The elimination of evil should be given precedence to the realization of benefit.
Even when adults of full capacity have the choice either to do a prescribed act or to ward off an evil, then warding off the evil takes precedence over achieving the benefit of performing the prescribed rewardable act. For instance, if someone were left to choose either to walk to the mosque on a rainy day with the possibility of catching a cold and falling sick or to perform the prayer at home, he should opt for the latter in order to ward off the potential harm. In such a situation, warding off the harm should be given precedence to gaining the reward for performing prayer at the mosque. A well-established legal maxim of the Islamic Jurisprudence is that the elimination of evil takes precedence over the realization of benefit.
There is no doubt that the doctors' advice should be acted upon in such cases; they are the specialists in this regard, and their opinions should be the key factor in arriving at a decision. If they have advised that sleeping on the side may incur harm on the baby, then the parents should not put him to sleep on his side even if it has other benefits. Warding off evils should be given precedence to bringing benefits, even if the benefits are religious in nature.
Allaah Knows best.