Yes sleeping with your legs elevated is good for you especially if you have heart problems or problems with blood flow or blood clots.
When you sleep with your legs elevated 6 to 12 inches above the heart it then takes pressure off the leg veins.
That is good for improving your blood flow and helping prevent blood clots.
So yes it's a good idea to sleep with your legs elevated to help keep your blood flowing properly and prevent heart attacks, strokes etc.
But if you're not comfortable sleeping in that position then you can still sleep in any position you prefer and are comfortable with and you'll still be okay.