Why do my back hurt when I sleep on my side?

Postural . Depending on your back anatomy some people will find certain positions may bother them. You might try sleeping on your back or if lying on your side bend your hips and knees with a pillow between your legs.
Bad bed. Your mattress is not giving you even support.