The piriformis is a small muscle located underneath or 'deep' to the gluteus maximus muscle. It runs diagonally from the sacrum and attaches to the upper portion of the femur within the hip.
The sciatic nerve runs underneath and through the piriformis.
FUNCTION OF THE PIRIFORMIS
The main function of the piriformis is to assist in hip rotation moving the leg and foot outward.
It's secondary function is to hold the sciatic nerve deep into the pelvis and hip so as to protect it from injury.
Because the sciatic nerve goes through the piriformis muscle both an overdeveloped or underdeveloped piriformis muscle can irritate the sciatic nerve causing sciatica. Read more about sciatica here.