It definitely was not gratuitous.
Female nudity is never gratuitous
I wonder how many times Kubrick made Kidman pose to get the shot right. 90, 100 times? I mean, her bare ass was vital to the plot. Cruise's ass though, not so much.